Finding top-n
Finding top-n
(OP)
Hi,
I need to write an sql query which will find the top n spenders in a table, based on the total the customers have spent which I have calculated already. Is there some form of "Clause" to enable me to do this? In JET SQL there is a command called top but it doesn't look ike this is available in interbase.
Best Regards
Paul Rowling
I need to write an sql query which will find the top n spenders in a table, based on the total the customers have spent which I have calculated already. Is there some form of "Clause" to enable me to do this? In JET SQL there is a command called top but it doesn't look ike this is available in interbase.
Best Regards
Paul Rowling
RE: Finding top-n
In IB6.5 and up, you can use the ROWS clause. In IB < 6.5, you have to write a SELECTable stored procedure to return just a few rows. Or you can simply open your resultset (ORDERed right) and close it after fetching your "n" rows.
Martijn Tonies
InterBase Workbench - the developer tool for InterBase and Firebird
http://www.upscene.com