PDA

View Full Version : SQl Query for Top and Bottom Row value for the particular date


jash
06-10-2009, 09:40 AM
I want to select First value and Last value for the particular date and Id

Table Ex.

ID DATE VALUE
001 23:04:2009 APPLE
001 23:04:2009 GRAPHE
001 23:04:2009 ROSE
001 24:04:2009 BERRY
001 24:04:2009 TIFFANY
001 24:04:2009 ORGANE
001 24:04:2009 SILVER


FOR 001 VALUE NEEDED –

APPLE AND ROSE FOR THE DATE OF 23:04:2009
BERRY AND SILVER FOR THE DATE OF 24:04:2009

Result Expected:

ID DATE VALUE
001 23:04:2009 APPLE
001 23:04:2009 ROSE
001 24:04:2009 BERRY
001 24:04:2009 SILVER


I tried Min, max, top condition but I am not getting a proper answer

SQL QUERY HELP urgent

meatashu
07-08-2009, 01:19 PM
you can use
select top 1 <columnname> from <tablename>
or
select bottom 1 <columnname> from <tablename>

hope it works !
:cool::)