how to select the top x number of records

if i have a field name called points in a table named blah, how do i write the query so that
it will select the top 40 records that have the most points, putting them in the correct order from highest to least?
Judy DeoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PE_CF_DEVCommented:
<cfquery name="blah" datasource="somewhere" maxrows=40>
Select *, points
from table
ORDER BY points DESC
</cfquery>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CFDevHeadCommented:
This should work for what you are trying to do
Select top 40 points from points_table order by points DESC

Hope this helps.
0
anandkpCommented:
in ORACLE i wld use

select points from (Select points from points_table order by points DESC) where rownum <= 40

K'Rgds
Anand
0
MauseCommented:
And for microsoft access:

<cfquery name="QUERYNAME" datasource="#DATASOURCE#">
         SELECT points
         FROM points_table
         ORDER BY points DESC
         LIMIT 40
</cfquery>

Mause
0
jayeshshahCommented:
in Ms-Access or Ms-SQL you can write the query as

SELECT top 40 * FROM points_table order by points table;


K'Regards

Jayesh
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.