How to extract the latest row

Posted by Bob on Stack Overflow See other posts from Stack Overflow or by Bob
Published on 2011-02-17T07:12:29Z Indexed on 2011/02/17 7:25 UTC
Read the original article Hit count: 121

Filed under:

Hi,

I have a table like this:

Table A
Date    Time    ID  Ref
110217  91703   A001    A1100056
110217  91703   A001    A1100057
110217  91703   A001    A1100058
110217  91703   A001    A1100059
110217  132440  A001    A1100057
110217  132440  A001    A1100058
110217  132440  A001    A1100060

I wish to have the latest data only & the final result should look like this using SQL:

Date    Time    ID  Ref
110217  132440  A001    A1100057
110217  132440  A001    A1100058
110217  132440  A001    A1100060

The database will self-update by itself at certain time. The problem is: I do not know the exact time, hence I do not know which record is the latest.

Thanks.

© Stack Overflow or respective owner

Related posts about sql