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
 Other Forums
 MS Access
 Displaying top 10 value of records

Author  Topic 

lsy
Yak Posting Veteran

57 Posts

Posted - 2005-09-13 : 20:42:29
can i query the top 10 value in database using sql statement??
i had a series of data... which i just want the top 10 largest value to be display...
pls advice...
eg:
counterA
6
11
5
3
12
7
10
2
8
9

i want it return as
counterA
12
11
10
9
8
7
6
5
4
3

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-09-13 : 21:15:49
SELECT TOP 10 CouterA FROM myTable ORDER BY CounterA DESC
Go to Top of Page

lsy
Yak Posting Veteran

57 Posts

Posted - 2005-09-14 : 04:59:21
if i have more than 10 record with the largest value it will show it as well then how can i control it?? which i just want 10 records...
eg:
counter a
12
12
12
12
12
12
12
12
12
12
12
12
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-09-14 : 05:09:15
SELECT TOP 10 CouterA FROM yourTable GROUP BY CounterA ORDER BY CounterA DESC

or

SELECT DISTINCT TOP 10 CouterA FROM yourTable ORDER BY CounterA DESC

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2005-09-14 : 05:11:52
SELECT distinct TOP 10 CounterA FROM yourTable ORDER BY CounterA DESC
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-09-14 : 05:14:19
Well Andrew
Just now I edited my reply

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

lsy
Yak Posting Veteran

57 Posts

Posted - 2005-09-14 : 05:42:13
thanks all...
Go to Top of Page
   

- Advertisement -