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
 General SQL Server Forums
 New to SQL Server Programming
 select top 5

Author  Topic 

ilans11il
Starting Member

2 Posts

Posted - 2015-04-10 : 09:52:51
Hi

from the below table I'd like to select the 3 top Price values

ProductID ProductName SupplierID CategoryID Unit Price
1 Chais 1 10 boxes x 20 bags 18
2 Chang 1 24 - 12 oz bottles 19
3 Syrup 2 12 - 550 ml bottles 10
4 Anton 2 48 - 6 oz jars 22
5 Chef 2 36 boxes 21.35
6 Grandma 2 12 - 8 oz jars 25
----------------------------------
I'd like to get:
Price
25
22
21.35

Thanks in Advanced

MichaelJSQL
Constraint Violating Yak Guru

252 Posts

Posted - 2015-04-10 : 09:55:49
SELECT TOP 3 * FROM Table Order by [Unit Price] DESC

- something like this?
Go to Top of Page

jcb267
Constraint Violating Yak Guru

291 Posts

Posted - 2015-04-10 : 10:12:55
select top 3 *
from [Your Table]
order by [Cost Field] desc
Go to Top of Page

jcb267
Constraint Violating Yak Guru

291 Posts

Posted - 2015-04-10 : 10:13:55
Is it 3 records or 5 you want?

If 5 change the 3 to a 5 above......
Go to Top of Page

ilans11il
Starting Member

2 Posts

Posted - 2015-04-10 : 10:57:51
Thank u very much
Go to Top of Page
   

- Advertisement -