🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#170
From: Bill Todd [TeamB]
Date: Tue, 01 Jul 2008 13:57
23 lines
1619 bytes
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: <486a37b6$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder.news-service.com!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>

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: "Bill Todd [TeamB]" <no@no.com>
Subject: Re: How to summarize (and group) the result of a union?
Newsgroups: borland.public.interbase.sql
References:  <4869f929$1@newsgroups.borland.com>
Organization: The Database Group, Inc.
User-Agent: XanaNews/1.18.1.9
X-Face: ":yn4zt^A_dn>6~{YJmu^B\'4w)e:apPM\VC=Dvf&*tASxX9|BYczkFd$xr.$vNSZ[3Uobr p]c4\+\l){!WQI.$]veP({HLd;CDYH?iN
NNTP-Posting-Host: 63.147.41.232
Message-ID: <486a37b6$1@newsgroups.borland.com>
Date: 1 Jul 2008 06:57:10 -0700
X-Trace: newsgroups.borland.com 1214920630 63.147.41.232 (1 Jul 2008 06:57:10 -0700)
Lines: 23
X-Authenticated-User: btodd
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!feeder.news-service.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail