| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: Can I do this using SQL?
Roy Hann wrote:
>>SELECT * >>FROM >> ( >> SELECT >> branch_name, >> SUM(acct_balance) AS activity_tot, >> COUNT(cust_id) AS cust_tally, >> ROW_NUMBER() OVER (ORDER BY SUM(acct_balance) DESC) AS rn >> FROM BranchActivity >> GROUP BY branch_name >>) dt >>WHERE rn <= 10;
That's why i wrote: "In Standard SQL you'll use ROW_NUMBER/RANK"
ROW_NUMBER -> exactly 10 rows
RANK -> then rows plus all the rows with the same value as the 10th.
DENSE_RANK -> all the rows with the 10 highest distinct values
Dieter Received on Fri Feb 10 2006 - 06:09:04 CST
![]() |
![]() |