From: | Lukasz Brodziak <lukasz(dot)brodziak(at)gmail(dot)com> |
---|---|
To: | PostgreSQL - newbie <pgsql-novice(at)postgresql(dot)org> |
Subject: | Select statement problem |
Date: | 2010-10-08 05:41:14 |
Message-ID: | AANLkTinVdPQVywTJWOZMPykcoMkhN9QdKTSzCaX5z=mE@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Hello,
I know the question may appear lame but I have problem with a SELECT
statement for a report. I have two separate statements:
SELECT t1.col1, t1.col2, SUM(t2.end_date::DATE - t2.start_date::DATE)
from table1 t1, table2 t2, table3 t3 WHERE t1.col3 = t2.col3 and
t3.col4 = t1.col4;
SELECT (Now()::DATE - t2.start_date::DATE) AS days
from table1 t1, table2 t2, table3 t3 WHERE t1.col3 = t2.col3 and
t3.col4 = t1.col4 and t2.end_date is null;
What I need is to have both statements' results presented in one table
which has 4 columns (t1.col1, t1.col2, "SUM", days). The tables used
are the same in both statements.
--
Łukasz Brodziak
II MU Bioinformatyka
From | Date | Subject | |
---|---|---|---|
Next Message | Frank Bax | 2010-10-08 10:45:13 | Re: Select statement problem |
Previous Message | Mladen Gogala | 2010-10-08 03:34:35 | Re: Asynchronous I/O in Postgres |