I have a table that contains records for EmployeeId, Project, Task and EntryDate. I'm trying to get a row number to be the same for every instance that the EmployeeId and month(date) are the same.
My sql statement looks like this:
ROW_NUMBER() OVER (EMPLOYEEID, month(EntryDate))
I also tried this:
ROW_NUMBER() OVER (PARTITION BY A.EMPLOYID ORDER BY A.EMPLOYID)
--figured I would remove the date to see if it would work correctly by employeeid
The problem is that I'm just getitng a new row number on every line even though all the records in the table have an Entry Date in May (i.e. 5/1/2015, 5/2/2015, 5/3/2015), etc.
What I'm getting is this:
Row Number, EmployeeId, Project, Task, Entry Date
1, EMP001, PROJA, TASK1, 5/1/2015
2, EMP001, PROJA, TASK2, 5/1/2015
3, EMP001, PROJA, TASK2, 5/2/2015
4, EMP002, PROJA, TASK1, 5/2/2015
What I want is this:
Row Number, EmployeeId, Project, Task, Entry Date
1, EMP001, PROJA, TASK1, 5/1/2015
1, EMP001, PROJA, TASK2, 5/1/2015
1, EMP001, PROJA, TASK2, 5/2/2015
2, EMP002, PROJA, TASK1, 5/2/2015
Any ideas on what I'm missing? I've tried Partition as well but still getting the same results.
Any help is greatly appreciated!