From: | "Morris, Sam(at)EDD" <SMorris(at)edd(dot)ca(dot)gov> |
---|---|
To: | "'pgsql-sql(at)postgresql(dot)org'" <pgsql-sql(at)postgresql(dot)org> |
Subject: | many to many relationship Query ? |
Date: | 1999-01-14 19:04:16 |
Message-ID: | D317C095B8FCD111BAA200805FE68574995C72@eddexmb04.cahwnet.gov |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
I am having problems composing query. I would like to compare the sums of
each table for a given date.
I have two tables :
T1.date T1.Amount
06/07/64 $1
06/07/64 $3
T2.date T2.date
06/07/64 $10
06/07/64 $20
I would like an output of :
T1.date Sum(T1.amount) Sum(T2.Amount)
06/07/64 $4 $30
I have tried:
select T1.date, Sum(T1.amount), Sum(T2.Amount)
from T1, T2
where T1.date="06/07/64" and T2.date="06/07/64"
group by T1.date;
This unfortunatly generates:
T1.date Sum(T1.date) Sum(t2.date)
06/07/64 $8 $30
What is the best way to do this?
From | Date | Subject | |
---|---|---|---|
Next Message | Christophe Labouisse | 1999-01-15 12:10:58 | Triggers, plpgsql, etc. |
Previous Message | Jackson, DeJuan | 1999-01-14 16:18:48 | RE: [SQL] A path through a tree |