SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 problem in select command
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

pooya1072
Starting Member

13 Posts

Posted - 03/16/2013 :  19:57:17  Show Profile  Reply with Quote
hi
please look at this select command :
select top 2 * from dbo.NFFeeds order by id desc

for my database the result is 2 rows .first by id=33 and second by id=32
by this command i get two last rows from my table . how can i get this two rows like this :
first row by id=32 and second row by id=33

James K
Flowing Fount of Yak Knowledge

3589 Posts

Posted - 03/16/2013 :  21:19:36  Show Profile  Reply with Quote
Do you mean this?
SELECT * FROM
( SELECT TOP 2 * FROM dbo.NFFeeds ORDER BY id DESC ) 
AS s ORDER BY id ASC;
Go to Top of Page

pooya1072
Starting Member

13 Posts

Posted - 03/17/2013 :  04:20:55  Show Profile  Reply with Quote
thank you very very much ... it's done
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000