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 2005 Forums
 SQL Server Administration (2005)
 order by twice

Author  Topic 

beza
Starting Member

16 Posts

Posted - 2009-03-01 : 17:14:54
Hey

I have a table with 2 columns.
CarName, Counter

what I want to do is select the top 20 rows sorted by counter and then I want to order those 20 rows by abc .. is it possible ??

the only thing I found was an ORDER BY with 2 clauses which is not good for this situation ... I can't seem to find the answer anywhere ...

any help would be greatly appreciated

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-03-01 : 19:02:19
SELECT *
FROM
(SELECT TOP 20 CarName, Counter, ABC FROM YourTable ORDER BY Counter) t
ORDER BY ABC

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -