🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

help with group by ..

#253
From: Karol Bieniaszewski
Date: Mon, 23 Jun 2008 11:08
45 lines
1848 bytes
Hi

i have problem with group by in this scenario

sumary by day in one row per day

tableA
ID Integer Primary key
DT DATE NOT NULL,
QU NUMERIC(18, 4),
PRICE NUMERIC(18, 2)

tableB
ID Integer Primary key
DT DATE NOT NULL,
QU NUMERIC(18, 4),
PRICE NUMERIC(18, 2)

i need some like
select
{A.DT or B.DT}, sum(A.QU), SUM(A.QU * A.PRICE), SUM(B.QU), SUM(B.QU * 
A.PRICE)
FROM
tableA
tableB

GROUP BY {A.DT or B.DT ... ????}

result should by like

DT                 SUMA       WARTA    SUMB   WARTB
2008-01-01   19               590            14          890
2008-01-02   12               789             11         654
................................................................

if i do this in this way

GROUP BY A.DT, B.DT i get mixed date sum


is this posible to do this in sql
or i must create stored procedure for this?

please help
Karol Bieniaszewski
Technical Details
Message-ID: <485f842b@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news1.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

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,8abde91de922829b,start
X-Google-Attributes: gid114a0e,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Karol Bieniaszewski" <liviuslivius@poczta.onet.pl>
Newsgroups: borland.public.interbase.sql
Subject: help with group by ..
Date: Mon, 23 Jun 2008 13:08:39 +0200
Lines: 51
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.5512
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 195.205.151.58
Message-ID: <485f842b@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1214219307 195.205.151.58 (23 Jun 2008 04:08:27 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news1.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: 1671