🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#169
From: Olivier Peter
Date: Tue, 01 Jul 2008 09:30
13 lines
1213 bytes
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?
Technical Details
Message-ID: <4869f929$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!feeder.news-service.com!news.isoc.lu!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,9f7a588667455f45,start
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: How to summarize (and group) the result of a union?
Newsgroups: borland.public.interbase.sql
X-User-Info: 78.20.190.102     
NNTP-Posting-Host: 207.105.83.66
Message-ID: <4869f929$1@newsgroups.borland.com>
Date: 1 Jul 2008 02:30:17 -0700
X-Trace: newsgroups.borland.com 1214904617 207.105.83.66 (1 Jul 2008 02:30:17 -0700)
Lines: 13
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news3.google.com!feeder.news-service.com!news.isoc.lu!newsgroups.borland.com!not-for-mail