From Christophe.Schockaert@spacebel.be Mon, 07 May 2001 13:04:03 -0700 From: "Christophe Schockaert" Date: Mon, 07 May 2001 13:04:03 -0700 Subject: SQL query needing Oracle cast Message-ID: MIME-Version: 1.0 Content-Type: text/plain Hi all, I need to get the top N values from a table. It's quite easy to formulate in english, but rather interesting to write in SQL. I found a solution at http://www.4guysfromrolla.com/webtech/110498-1.shtml The example has a table ItemCost containing ItemNumberID (int) and Cost (money). The query is: SELECT rank, ItemNumberID, Cost FROM (SELECT T1.ItemNumberID, T1.Cost, (SELECT COUNT(DISTINCT T2.Cost) FROM ItemCost T2 WHERE T1.Cost <= T2.Cost) AS rank FROM ItemCost T1) AS X WHERE rank>>>---------------> mailto:Christophe.Schockaert@spacebel.be Once it's perfectly aimed, the flying arrow goes straight to its target. Thus, don't worry when things go right. There will be enough time to worry about if they go wrong. Then, it's time to fire a new arrow towards another direction. Don't sink. Adapt yourself ! The archer has to shoot accurately and quickly. [Words of Erenthar, the bowman ranger] <---------------<<<< -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Christophe Schockaert INET: Christophe.Schockaert@spacebel.be Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru@fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).