I am looking for assistance to add a column to my table which sequences (1,2,3...) each row based on date and grouped by userID as shown in the mockup below. Not sure if I have to join the table on itself and count, or whether there is a more efficient function. Im using SQL Server 2008 R2.
| Username | Date |
--------------------------
| Username1 | 01/1/2014 |
| Username1 | 02/1/2014 |
| Username1 | 03/1/2014 |
| Username2 | 01/4/2014 |
| Username2 | 01/6/2014 |
| Username3 | 02/3/2014 |
| Username3 | 05/8/2014 |
| Username4 | 01/9/2014 |
| Username1 | 08/1/2014 |
| Username5 | 07/1/2014 |
| Username | Date |Seq |
------------------------------
| Username1 | 01/1/2014 | 1 |
| Username1 | 02/1/2014 | 2 |
| Username1 | 03/1/2014 | 3 |
| Username2 | 01/4/2014 | 1 |
| Username2 | 01/6/2014 | 2 |
| Username3 | 02/3/2014 | 1 |
| Username3 | 05/8/2014 | 2 |
| Username4 | 01/9/2014 | 1 |
| Username1 | 08/1/2014 | 4 |
| Username5 | 07/1/2014 | 1 |