I have a table with this data:
ID voting_ID username timestamp XMLBallot
1 9 voter01 23. 4. 2012 8:54:45 xmldata
2 9 voter01 21. 4. 2012 14:00:34 xmldata
3 9 voter02 20. 4. 2012 16:01:10 xmldata
4 11 voter01 23. 4. 2012 8:40:45 xmldata
5 9 voter03 19. 4. 2012 21:18:49 xmldata
I need to get only one newest ballot for each voter (username) in specific voting_ID
.
For example data I need to be returned for @voting_ID=9
ID voting_ID username timestamp XMLBallot
1 9 voter01 23. 4. 2012 8:54:45 xmldata
3 9 voter02 20. 4. 2012 16:01:10 xmldata
5 9 voter03 19. 4. 2012 21:18:49 xmldata
Please help me build that SQL Server 2008 query.. thank you
PS: table name is ballots