Write a sql to get the last data
Posted
by Lu Lu
on Stack Overflow
See other posts from Stack Overflow
or by Lu Lu
Published on 2010-05-06T06:59:52Z
Indexed on
2010/05/06
7:18 UTC
Read the original article
Hit count: 349
Hello everyone, I have a Realtime table with example data:
Symbol Date Value
ABC 1/3/2009 03:05:01 327 -- is last data for 'ABC'
ABC 1/2/2009 03:05:01 326
ABC 1/2/2009 02:05:01 323
ABC 1/2/2009 01:05:01 313
BBC 1/3/2009 03:05:01 458 -- is last data for 'BBC'
BBC 1/2/2009 03:05:01 454
BBC 1/2/2009 02:05:01 453
BBC 1/2/2009 01:05:01 423
Please help me to write a sql to return last data for all symbol. The result is:
Symbol Date Value
ABC 1/3/2009 03:05:01 327
BBC 1/3/2009 03:05:01 458
P/s: I use sql server 2005. And Realtime data is very big, please optimize the sql code.
Thanks.
© Stack Overflow or respective owner