i have a table with jobs like this in a MS SQL Server 2008 database:
J_ID J_Name J_ReadDate J_I_ID
`````````````````````````````````````````````````````````
01 Job1 2011-06-26 01:00:12.153 1
02 Job2 2011-06-25 01:00:07.103 1
03 Job3 2011-06-25 01:00:07.103 2
04 Job4 2011-06-25 01:00:07.103 3
05 Job1 2011-06-26 01:00:07.103 1
06 Job2 2011-06-26 01:00:08.103 2
07 Job1 2011-06-26 01:00:08.103 2
now i want to select only the newest jobs, no matter how old the entry is. So in my example it would like to get this result (ordered by J_ReadDate DESC):
J_ID J_Name J_ReadDate J_I_ID
`````````````````````````````````````````````````````````
06 Job2 2011-06-26 01:00:08.103 2
07 Job1 2011-06-26 01:00:08.103 2
05 Job1 2011-06-26 01:00:07.103 1
03 Job3 2011-06-25 01:00:07.103 2
04 Job4 2011-06-25 01:00:07.103 3
how can I achieve this? I cannot say, that the time difference between the entries is always one day.
The below will get what you’re after.