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.
| Author |
Topic |
|
constantinos1987
Starting Member
25 Posts |
Posted - 2008-11-29 : 12:47:15
|
| i want to find the 3 customers with the maximum sales_amount. in case of draw i would like to project all of them |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-29 : 12:49:57
|
| [code]select top 3 * with ties from your table order by sales_amount desc[/code] |
 |
|
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2008-11-29 : 23:41:21
|
That should beselect top 3 with ties * from your table order by sales_amount desc |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-30 : 01:34:55
|
or if sql 2000 useselect * from yourtable tinner join (select top 3 sales_amount from yourtable order by sales_amount desc) tmpon tmp.sales_amount=t.sales_amount |
 |
|
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2008-11-30 : 01:40:57
|
quote: Originally posted by visakh16 or if sql 2000 useselect * from yourtable tinner join (select top 3 sales_amount from yourtable order by sales_amount desc) tmpon tmp.sales_amount=t.sales_amount
TOP x WITH TIES is available in SQL Server 2000 |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-30 : 01:46:08
|
quote: Originally posted by snSQL
quote: Originally posted by visakh16 or if sql 2000 useselect * from yourtable tinner join (select top 3 sales_amount from yourtable order by sales_amount desc) tmpon tmp.sales_amount=t.sales_amount
TOP x WITH TIES is available in SQL Server 2000
yup it isi thought its available only from 2005 |
 |
|
|
|
|
|