I have a user data table in my SQL Server database and am trying to summarize the data. Basically I need some values of min, max and sum and group by some columns
Here is an example table:
Member ID | Name | DateJoined | DateQuit | PointsEarned | Address
00001 | Leyth | 1/1/2013 | 9/30/2013 | 57 | 123 FirstAddress Way
00002 | James | 2/1/2013 | 7/21/2013 | 34 | 4 street road
00001 | Leyth | 2/1/2013 | 10/15/2013| 32 | 456 LastAddress Way
00003 | Eric | 2/23/2013 | 4/14/2013 | 15 | 5 street road
I would like the summary table to display the following results:
Member ID | Name | DateJoined | DateQuit | PointsEarned | Address
00001 | Leyth | 1/1/2013 | 10/15/2013 | 89 | 123 FirstAddress Way
00002 | James | 2/1/2013 | 7/21/2013 | 34 | 4 street road
00003 | Eric | 2/23/2013 | 4/14/2013 | 15 | 5 street road
Here is my request:
Select MemberID, Name, Min (DateJoined), Max (DateQuit), SUM (PointsEarned), Min (Address) From the GroupID MemberID table
This time Min (Address) works, it gets the address corresponding to the earliest DateJoined. However, if we replaced the two addresses in the source table, we would retrieve 123 FirstAddress Way that would not match the join date 1/1/2013.
Thanks, go ahead
source
share