Assume I have the following pretty big table (350+ million rows):
Create table test(
col1 int, -- there is an index on this column
col2 datetime,
...
...
)
Sometimes I want to be able to pull only records that match against col1 however since there are duplicates, I want only the ones with the latest timestamp.
For example:
select * from test where col1 in (123, 389, 192) AND only give me the record for each match against col1 that has the latest timestamp.
So in a table that contains:
123, 2015-08-23,....
123, 2015-09-23,....
it would return only the second record for value 123 which has a date of 2015-09-23.
Thanks