SELECT id, qty
FROM table
ORDER BY qty DESC

To only pick the top X number, you can use the "TOP" command in SQL server,
as "select top 3 id, qty" or the "maxrows" attribute of the CFQUERY tag.

-Justin Scott, Lead Developer
 Sceiron Internet Services, Inc.
 http://www.sceiron.com


----- Original Message -----
From: "Jake McKee" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Saturday, April 27, 2002 3:07 PM
Subject: Top Ten Results


> All,
>
> I have what will hopefully be an easy question.
>
> I have a DB with two columns ID and Qty.
>
> I am trying to figure out how to select the 3 ID (or however many) that
> have the largest Qty. For instance if this is my table:
>
> 1    43
> 2    6
> 3    55
> 4    645
> 5    2
> 6    78
> 7    32
> 8    30
> 9    45
> 10   90
>
> then the results would return:
>
> 4
> 10
> 6
>
>
>
> Please help!
>
> 
______________________________________________________________________
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to