🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: How to summarize (and group) the result of a union?

#171
From: Olivier Peter
Date: Tue, 01 Jul 2008 14:19
30 lines
1883 bytes
I've been thinking about a view too, but i was still hoping for a more flexible solution. 

Thanks Bill.


"Bill Todd [TeamB]" <no@no.com> wrote:
>Olivier Peter wrote:
>
>> 
>> I want to make a sum of amount grouped by year, month, week and day
>> based on the result set of a union.  However, when i try the
>> following i get an error on line three token unknown SELECT.
>> 
>> SELECT YEAR, MONTH, WEEK, DAY, SUM(AMOUNT) FROM
>> (
>> SELECT YEAR, MONTH, WEEK, DAY, AMOUNT FROM TABLE1
>> UNION
>> SELECT YEAR, MONTH, WEEK, DAY, AMOUNT FROM TABLE2
>> )
>> GROUP BY YEAR, MONTH, WEEK, DAY
>> 
>> Any ideas how to make this work?
>
>InterBase does not support derived tables. Create a view with the UNION
>then select from the view. Unless you want duplicates dropped use UNION
>ALL for better performance.
>
>-- 
>Bill Todd (TeamB)
Technical Details
Message-ID: <486a3cf4$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4869f929$1@newsgroups.borland.com> <486a37b6$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,9f7a588667455f45
X-Google-Attributes: gid114a0e,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Olivier Peter" <peterolivier@hotmail.com>
Sender: "Olivier Peter" <peterolivier@hotmail.com>
Reply-To: "Olivier Peter" <peterolivier@hotmail.com>
Subject: Re: How to summarize (and group) the result of a union?
Newsgroups: borland.public.interbase.sql
X-User-Info: 78.20.190.102     
References:  <4869f929$1@newsgroups.borland.com> <486a37b6$1@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <486a3cf4$1@newsgroups.borland.com>
Date: 1 Jul 2008 07:19:32 -0700
X-Trace: newsgroups.borland.com 1214921972 207.105.83.66 (1 Jul 2008 07:19:32 -0700)
Lines: 31
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
X-Original-Bytes: 1655