• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • Last Modified:

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?
0
Judy Deo
Asked:
Judy Deo
5 Solutions
 
PE_CF_DEVCommented:
<cfquery name="blah" datasource="somewhere" maxrows=40>
Select *, points
from table
ORDER BY points DESC
</cfquery>
0
 
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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now