Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> comp.databases.theory -> Re: Can I do this using SQL?

Re: Can I do this using SQL?

From: Roy Hann <specially_at_processed.almost.meat>
Date: Fri, 10 Feb 2006 09:22:37 -0000
Message-ID: <Ksqdnf7S2P14xnHenZ2dnUVZ8qednZ2d@pipex.net>


"Dieter Noeth" <dnoeth_at_gmx.de> wrote in message news:dshleb$ml8$1_at_online.de...
> 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;

Appealing but wrong. And I have the bruises to prove it.

You are just arbitrarily choosing 10 rows, not the all rows with values that would place them in the top 10. (Consider the possibility that acct_balance is identical for all branches.)

Roy Received on Fri Feb 10 2006 - 03:22:37 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US