Re: Can I do this using SQL?
From: Tony Rogerson <tonyrogerson_at_sqlserverfaq.com>
Date: Fri, 10 Feb 2006 08:25:49 -0000
Message-ID: <dshilm$6p0$1$8302bc10_at_news.demon.co.uk>
Date: Fri, 10 Feb 2006 08:25:49 -0000
Message-ID: <dshilm$6p0$1$8302bc10_at_news.demon.co.uk>
What, CELKO writing a cursor?
I'm shocked!
In SQL Server you would write...
SELECT TOP 10 branch_name,
Which gives you a result set you can use, whereas with standard SQL you
SUM(acct_balance) AS activity_tot,
COUNT(cust_id) AS cust_tally
FROM BranchActivity
GROUP BY branch_name
ORDER BY activity_tot;
-- Tony Rogerson SQL Server MVP http://sqlserverfaq.com - free video tutorials "-CELKO-" <jcelko212_at_earthlink.net> wrote in message news:1139540128.434166.136380_at_g44g2000cwa.googlegroups.com...Received on Fri Feb 10 2006 - 09:25:49 CET
>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.
>