October 11th, 2013, 09:09 AM
Need Grouping Help - Probably easy
I have a a dataset which I need to collapse and don't know how.
I have 2 records which I want to sum and make 1. The 2 records have matching identifying number however they have different names. I don't care which name lives through to the result but I need one to. I tried MAX but that didn't work. See Below for example
Record 1: Name: Red, Dollars: 5, Identity: 612
Record 2: Name: Red Tree, Dollars: 10, Identity 612
So for my result I would like it to be a total dollars of 15, Identity 612, and for Name I just need it to pick 1, I don't care if it's Red or Red Tree.
Your help is greatly appreciated. Thanks!
October 11th, 2013, 09:12 AM
SELECT SUM(Dollars) AS totaldollars, MIN(Name) AS randomname, Identity
GROUP BY Identity;
I doubt very much that you can get away with just selecting anty random name but I guess you've thought about that :-)