>CaptureDate EDP AlertFlg >2009-01-05 15:28:21.860 15382 Zero >2009-02-05 15:29:32.860 15382 Scheduled >2009-03-05 15:29:31.860 15382 Low >2009-01-05 15:28:21.860 32522 BO >2009-02-05 15:29:32.860 32522 Zero >2009-03-05 15:29:31.860 32522 Zero > > >EDP AlertFlg >15382 Low >32522 Zero >>
select * from (select *, row_Number() over (Order by CaptureDate DESC) as RowNumber from myTable) D where RowNumber = 1BTW, if you have multiple records with the same date, then this solution would not work, you can use RANK() instead.