I am trying to write a query that displays the total value sold of items in a product line. For some of these items, only one row is needed to return the answer. For others, two or more rows need to be added together to get the correct value. The issue is that the Item ID's for some of the items do not indicate that they should go together (Item ID 1030, 1031, 5032, and 1033 may go together). There is no column that I can group these on, so I figure I will have to do it by hand.
Is there anyway to add together specific values in the same column?
Here is a small demonstration of what I am talking about. In the first column I have the ID of the item, and the second column contains the value. I need to add the value together for rows that are in the same product line. Unfortunately, the Item ID is only similar sometimes, but other times the ID's do not fit with the others.
GROUP BYtogether withLEFT JOINto get the final result. You can also useISNULLto set a suitable default for those products where you don't product details. Do you have some sample data/table design?