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: -CELKO- <jcelko212_at_earthlink.net>
Date: 9 Feb 2006 18:55:28 -0800
Message-ID: <1139540128.434166.136380@g44g2000cwa.googlegroups.com>


I assume that a big balance is how you rate the branches.

DECLARE BestTenBranches CURSOR FOR
SELECT branch_name, SUM(acct_balance) AS activity_tot, COUNT(cust_id) AS cust_tally
  FROM BranchActivity
GROUP BY branch_name
ORDER BY activity_tot;

The TOP n operator is a SQL Server extension, but you can do this with a cursor in Standard SQL, as shown. Received on Thu Feb 09 2006 - 20:55:28 CST

Original text of this message

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