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)
 get 2 sets of top records from one table

Author  Topic 

JNotenboom
Starting Member

27 Posts

Posted - 2001-02-28 : 07:16:35
Hi,

With a union, you can only use one ORDER BY. But suppose I want to get, for example, the top 10 of sales and the top 15 of profit from one and only one table.
can I do this in one SQL Statement?
The following does not work but will define what I mean:
select top 10 Sales, *
from Customers
Order by Sales DESC
union
select top 15 Profit, *
from Customers
Order by Profit DESC

thanx in advance!

   

- Advertisement -