🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.interbase.sql
Article #69

Re: can I do that with one select statement

#69
From: Isaac
Date: Tue, 27 May 2008 13:54
21 lines
1489 bytes
Maxim Shiryaev wrote:
> Hi.
> 
> Try:
> 
> for
>   select field_a, sum(field_b)
>   from t
>   group by field_a
>   into :v_a, :v_sum_b
> do begin
>   if (v_a) = 1 then some_var_1 = v_sum_b;
>   else if (v_a) = 2 then some_var_2 = v_sum_b;
>   /* and more if's if ther are more distinct values in field_a */
> end
Is this faster than using Two Selects

Select sum(f2) from table_1 where f1 = 1
Select sum(f2) from table_2 where f1 = 0

Thanks
Technical Details
Message-ID: <483c12b2@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <483bca8e@newsgroups.borland.com> <483bf82c@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,e4861ce108d51b43
X-Google-Attributes: gid114a0e,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Tue, 27 May 2008 16:54:46 +0300
From: Isaac <no@no.com>
User-Agent: Thunderbird 2.0.0.14 (Windows/20080421)
MIME-Version: 1.0
Newsgroups: borland.public.interbase.sql
Subject: Re: can I do that with one select statement 
References: <483bca8e@newsgroups.borland.com> <483bf82c@newsgroups.borland.com>
In-Reply-To: <483bf82c@newsgroups.borland.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 41.234.198.147
Message-ID: <483c12b2@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1211896498 41.234.198.147 (27 May 2008 06:54:58 -0700)
Lines: 21
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
X-Original-Bytes: 1305