Click here to Skip to main content
15,890,825 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i need use multiple top

example

SQL
Select top 5  OrderID from Orders where ShipVia in
(Select ShipperID from Shippers where CompanyName = 'Speedy Express' and CompanyName = 'United Package')


i need top 5 Speedy Express and top 5 United Package orders
Posted

1 solution

This Will Help you.....


SQL
SELECT * FROM (
SELECT top 5  OrderID FROM Orders WHERE ShipVia IN
(SELECT ShipperID FROM Shippers WHERE CompanyName = 'Speedy Express' )

UNION ALL


SELECT top 5  OrderID FROM Orders WHERE ShipVia IN
(SELECT ShipperID FROM Shippers WHERE  CompanyName = 'United Package')) AS Tbl1
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900