I have a scenario where I have two tables ORDER ORDER_NO LOCATION ITEM QTY_RECEIVED SHIPMENT ORDER_NO LOCATION ITEM QTY_RECEIVED There are cases where ORDER table has a record but SHIPMENT table …
Tag: group-by
SQL turning rows into columns and populating with values
I’m not quite sure why this table was designed this way, but it’s making it hard to solve my problem. Looking at the data: What I need help with is to do the following: For each name have the type_name as a column and then fill those columns with the default_value or value. Like this: Basically populates from default_value or
Group by not getting the expected results in mysql
I have the next query: That is working perfectly and returning 9 rows: I want to group the results by boat type and get the number of boats per type. However, when I do: I´m getting: but according to the first query, I´m expecting What am I missing? Answer I suspect that you want: That is: move the DISTINCT within
Find total count and average based of values from another table
In Mysql: I have customer name (primary key), cities and an amount in table: Table Cities: customer location amount Cust1 New York, USA 200 Cust2 New York, USA 300 …
Combining query results for number of records in a single row
I am new to SQL. I have a table that has billion of records with multiple columns, let’s say a,b,c,d,e,f. I would like to create a query for number of records for each column with certain condition …
MYSQL SUM(IF) with group by NAME but some NAME wanna makes sum
I have one question in SQL. This is the query. it makes a result below: but I wanna make Customer A and B sum together as A(not B) or new name(e.g. Z) like this: I want to modify the query and output it. Answer I understand that you want to group together customers A and B. You can do this
How to get the sum of a subquery that returns sums?
I would like to get the sum of the “sums” in the following case. How can I do that? The following picture represents the table I receive after performing the code below. I’d like to receive only 2 …
Mysql Group By age by range [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question i need help, i need to create report like this the report is group by the age, but i can’t get when age under <=
SQL statement HOW to count all relevant rows (A,B) and (B,A) together
I am trying to count all rows where seller and buyer has also an inverted relationship. So the buyer sells to seller. I do not have any clue to group them together. Table T1| ———————- …
Selecting new distinct values over time (ORACLE SQL)
I want to select new distinct values and track them over time. I have a table where each row represents a score awarded to a particular person. – timestamp (when the score was awarded) – name (which person received the score) – score (what score the person received) I want the result to look like: The above table should be