Select first and last occurrence of repeated colums in sql server
I have a table like this,
Date is in yyyy-mm-dd format
Name       Date          Credits
--------------------------------
Bill      2013-04-04       5
Paul      2013-04-05       4
Bill      2013-04-05       3
Angel     2013-04-07       9
Bill      2013-05-01       8
Paul      2013-05-02       7
Bill      2013-06-15       6
Angel     2013-07-22       15
Paul      2013-07-23       7
Angel     2013-08-11       9
And my expected result is
Name       MinDate      MaxDate        Credits
-----------------------------------------------
Bill      2013-04-04    2013-06-15       1
Paul      2013-04-05    2013-07-23       3
Angel     2013-04-07    2013-08-11       0
How to form the Query. Help needed.
 
No comments:
Post a Comment