-
September 13th, 2005, 03:57 AM
#1
query top10 value
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...
-
September 13th, 2005, 04:10 AM
#2
Re: query top10 value
something like
Code:
SELECT TOP 10 field_name FROM table_name ORDER BY field_largest DESC
plz give more detail like table name, table value if it's not working
-
September 13th, 2005, 04:18 AM
#3
Re: query top10 value
Originally Posted by erickwidya
something like
Code:
SELECT TOP 10 field_name FROM table_name ORDER BY field_largest DESC
plz give more detail like table name, table value if it's not working
this will return the top 10 record not the value of a column...
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
you get what i means?
-
September 13th, 2005, 06:52 AM
#4
Re: query top10 value
I would query it like this :
Code:
SELECT field_name FROM tabl_name ORDER BY field_largest DESC LIMIT 10
Thats how I do it, and it ususally works...
Rate this post if you found it useful!
10X, gilly914
-
September 13th, 2005, 07:31 PM
#5
Re: query top10 value
Originally Posted by gilly914
I would query it like this :
Code:
SELECT field_name FROM tabl_name ORDER BY field_largest DESC LIMIT 10
Thats how I do it, and it ususally works...
It does not work... i'm using MS Access to make this query... it does not recognise the LIMIT 10... pls advice...
-
September 13th, 2005, 08:12 PM
#6
Re: query top10 value
Originally Posted by lsy
this will return the top 10 record not the value of a column...
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
you get what i means?
I do not beleive this to be correct.
The order by will be called before the top 10 is selected, which should give you what you desire. This will work in Access.
So, as Erick suggested, I think this is what you need:
Code:
SELECT TOP 10 field_name FROM table_name ORDER BY field_largest DESC
Hope this helps,
- Nigel
-
September 13th, 2005, 08:41 PM
#7
Re: query top10 value
try this one
Code:
SELECT TOP 10 CounterA from table_name ORDER BY CounterA DESC
-
September 14th, 2005, 02:28 AM
#8
Re: query top10 value
>>SELECT field_name FROM tabl_name ORDER BY field_largest DESC LIMIT 10
That is for MySQL
>>this will return the top 10 record not the value of a column...
Did you try the Query suggested by erickWidya
Thats the answer
It seems you didnt try that
What do you mean by "this will return the top 10 record not the value of a column..."?
Madhivanan
Failing to plan is Planning to fail
-
September 14th, 2005, 04:16 AM
#9
Re: query top10 value
Thanks all.... i been success to query about... but right now i have some concern if i have a largest value data which have more than 10 times how can i control which only display 10 record??
eg:
counter a:
12
12
12
12
12
12
12
12
12
12
12
12
12
-
September 14th, 2005, 04:20 AM
#10
Re: query top10 value
Select Distinct Top 10 CounterA from yourTable ORDER BY CounterA DESC
Madhivanan
Failing to plan is Planning to fail
-
September 14th, 2005, 04:48 AM
#11
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|