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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 top 20 records: sort first or last?

Author  Topic 

Sun Foster
Aged Yak Warrior

515 Posts

Posted - 2005-09-29 : 09:25:34
I want to select top 25 orders which based on desc sorting in Order table (it did not sort). I use code like:

SELECT TOP 25 OrderID, OrderDate
FROM tblOrder ORDER BY OrderDate DESC;

Question: These top 25 are selected after "ORDER BY OrderDate DESC" or select randomly from Order table and then "ORDER BY OrderDate DESC"?

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-09-29 : 09:33:23
order by is first then top is applied.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-09-29 : 09:34:27
Your query is correct
Are you using SQL Server2000 or Access?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Sun Foster
Aged Yak Warrior

515 Posts

Posted - 2005-09-29 : 09:48:56
SQL server2000.
Thank you.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-09-29 : 09:50:46
Then that query will work
Post some sample data and the result you want

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -