Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Query should Return only 1 record

Author  Topic 

bhanu2217
Starting Member

35 Posts

Posted - 2010-05-03 : 06:48:31
I have the following query but i want the only top most record.

SELECT * FROM enp_newspaper where Date <'20100503' order by Date asc



www.JamboreeBliss.com

bhanu2217
Starting Member

35 Posts

Posted - 2010-05-03 : 06:55:27
SELECT top 1 date FROM enp_newspaper where Date <'20100503' order by Date asc

I tried this and it works but i want it to return all the fields rather then just date.

www.JamboreeBliss.com
Go to Top of Page

bhanu2217
Starting Member

35 Posts

Posted - 2010-05-03 : 06:56:36
I got it. Thank You.

SELECT top 1 * FROM enp_newspaper where Date <'20100503' order by Date asc

Solved.

www.JamboreeBliss.com
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-05-03 : 09:43:27
is there a chance that you've multiple records with same max date value? in that case, do you still want to return only one of them?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -