Concatenated numbers stuck in scientific notation MS Access - ms-access

I am trying to concatenate two columns of numbers, Column A and Column B. Both columns are stored as numbers in the underlying table. Column A varies from 1-9 numbers, and Column B is 2 or 3 numbers. The combination of 9 numbers in column B and 3 numbers in column B forces column A to be displayed in scientific notation before merging with Column B, resulting in an error.
So far I have tried the following expressions:
[Table].[ColumnA]&[Table].[ColumnB]
Val([Table].[ColumnA]&[Table].[ColumnB])
FormatNumber([Table].[ColumnA]&[Table].[ColumnB],0)
It seems like "&" is forcing columns A and B into text to be joined, but any formatting functions are converting after. How do I make sure both columns stay numbers before, during and after merging?

Set field in table as LongInteger or Double type and then all 9 digits should display. Do not use Single or Integer.
Or use CDbl([ColumnA]) in query.
Regardless, the result of concatenation is a string, not a number value.

You missed the last combination:
Format([Table].[ColumnA],"0") & Format([Table].[ColumnB],"0")

Related

Why do we use UNION to join rows in SQL?

Why use union in Sql at all when there must be same order of columns and it's names in the select statements. Couldn't we just update or alter the table to add more rows ?
The reason that you would not just keep adding rows to a single table is that they don't belong in that table.
For the same reason that if you're doing arithmetic between two integer variables like x + y, you don't permanently add the value of y to x. You want to preserve x's value as it's own thing, even though sometimes you also need the sum.
A book like SQL and Relational Theory: How to Write Accurate SQL Code makes clear that there's a difference between a relation and a relvar. A relvar is like a table. It's a persistent storage of a specific set of rows.
A relation is the result of a SQL expression like SELECT or VALUES. That relation may not be stored in any relvar; it is ephemeral. Perhaps it's the result of a more complex query that uses expressions, joins, and so on.
By analogy, the a number like 42 is an integer value. But int x that stores an integer value 42 is an integer variable. They can both be used as an operand for + but they're not the same kind of thing.
You can UNION two relations, if their columns are compatible in number and data type. Those relations aren't necessarily just relvars, they could be the result of other subqueries.
Just like in arithmetic, you can add x and a whole other integer expression.

How do I log the the sum of values from multiple rows to a new row if the value in the column next to it matches

You will need this solve this.
In this sheet, I am trying to take the scores of the people and log them in the "Week Total" Column L as a sum. The names often exist in each column for that days score. I need to take their score for each day next to their name, and log it next to their name in Column L as a total if that makes sense.
So if Bob got a 10 on Monday, a 10 on Tuesday, and X the rest of the days, then I need to log that in Column L next to his name as "20".
I am using the Unique function to log all their names under Column K.
Thank you!
You can use query and combine it with some array notations.
Formula:
=query({{A4:A,B4:B};{C4:C,D4:D};{E4:E,F4:F};{G4:G,H4:H};{I4:I,J4:J}}, "select Col1, sum(Col2) where Col1 is not null group by Col1 label sum(Col2) ''", 0)
Output:
Note:
A duplicate Bob can be seen as you have spaces after Bob on some cells (e.g. Bob ). Make sure to have no spaces with them when inputting to remove duplicates from the formula result, or just use trim before using them. See modified formula before:
Formula with trim:
=query(index({{trim(A4:A),B4:B};{trim(C4:C),D4:D};{trim(E4:E),F4:F};{trim(G4:G),H4:H};{trim(I4:I),J4:J}}), "select Col1, sum(Col2) where Col1 is not null group by Col1 label sum(Col2) ''", 0)
Result:
You're not making your life easier by inputting X since that will be read as text, I'd recommend using 0 instead (if you insist on X then add an IF statement to exclude the Xs).
But what you're looking for is =SUMIF() coupled with some smart Array notation as demonstrated here in the documentation.
Create arrays
You can also create your own arrays in a formula in your spreadsheet by using brackets { }. The brackets allow you to group together values, while you use the following punctuation to determine which order the values are displayed in:
Commas: Separate columns to help you write a row of data in an array. For example, ={1, 2} would place the number 1 in the first cell and the number 2 in the cell to the right in a new column.
Semicolons: Separate rows to help you write a column of data in an array. For example, ={1; 2} would place the number 1 in the first cell and the number 2 in the cell below in a new row.
Note: For countries that use commas as decimal separators (for example €1,00), commas would be replaced by backslashes () when creating arrays.
You can join multiple ranges into one continuous range using this same punctuation. For example, to combine values from A1-A10 with the values from D1-D10, you can use the following formula to create a range in a continuous column: ={A1:A10; D1:D10}.
Adding arrays to existing formulas
You can also use arrays with other existing formulas using brackets in order to organize the returns from your formulas into rows or columns.
For example, ={SUM(A1:A10), SUM(B1:B10)} will produce two values. The first cell will contain the sum of A1 to A10, the cell to the right will contain the sum of B1 to B10.

Understanding the use of bitwise operators in MySQL?

Can someone explain the purpose of using bitwise operators(like BIT_OR) in MySQL queries. For example, if have a table such as following:
What is the purpose of aggregate operation like:
SELECT name FROM table GROUP BY name HAVING BIT_OR(value) = 0;
What exactly does the BIT_OR do? I understand the actual operation of converting two integers to binary and determining if each pair of corresponding digits are either 0 or 1(if at least one of them is a 1), but what happens with varchar or other non-number columns columns? I know for example, SUM aggregate function can give me the sum of a column of each group. Likewise, what does BIT_OR tell me for each group?
**NOTE:**I randomly created the above table and query - it doesn't illustrate any specific problem

Select only row columns with values not equal to

I wonder if it is possible with MySQL. I output the result of my "select" query. The result is always one single row. What I want is to output only columns with values not equal to 0. I do not want the user to see everything because lots of columns in the row are 0 and thus not interesting for him.
Example row:
column name: a b c d e f
column value: 1 6 0 6 7 0
I do not want columns c and f to appear in the result.
Can that be achieved in SQL resp. MySQL? Or do I have to perform additional processing of SQL result with some programming language like PHP?
Best regards
Ewgenij
You can't have dynamic columns with a static query.
The only way to have dynamic columns in MySQL is with a stored procedure (which will have to build a query as a string and run it).

SQL counting the top occurrences of substrings seperated by commas in a column

I have a column in MYSQL with a list of comma-separated names of varying lengths. Some example columns would be: ,bob,joe,mike, or ,steve,bill,dan,.
I'm looking to sort by the names that occur the most in all columns and be able to count how many times they occur. For example it could return that Joe is the most common name with x occurrences in all of the columns and that bob is the second most common name with y occurrences in all of the columns.
Is there an effective way to go about this or am I better off storing each name individually as their own record? This table has records added to it quite often so if I could cut down on the size that would be ideal.
I would definitely go for storing these values as 1 row each in the 'name' column of a 1-many table. That way you can use aggregate functions easily.