From: | Bryan Lee Nuse <nuse(at)uga(dot)edu> |
---|---|
To: | Oliveiros d'Azevedo Cristina <oliveiros(dot)cristina(at)asperger-talents(dot)com> |
Cc: | James David Smith <james(dot)david(dot)smith(at)gmail(dot)com>, "<pgsql-novice(at)postgresql(dot)org>" <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: Joining time fields? |
Date: | 2012-07-26 19:35:17 |
Message-ID: | E04ACAA2-35E8-4919-AB3A-8D2E47F2F1A4@uga.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Hello Oliver, James,
Thanks, Oliver, for your encouragement. As a relative SQL novice myself, I've benefited a lot from this and the other pg mailing lists -- so, I'm now trying to contribute when I can.
Yes, I should have mentioned I'm using version 9.1.
I think the only tricky thing I did was use the WITH construct to give names ("crossed", "grouped") to the two subqueries. I guess I should have made that more clear. These are simply called from within the body of the outer query. It just makes the code look cleaner, in this case.
I gave the wrong output from my test case, in the previous post. Here's what it should be:
dt_a | let_a | dt_b | let_b | interval
---------------------+-------+---------------------+-------+-----------
1993-10-06 04:36:09 | D | 1994-05-16 06:45:20 | X | 19188551
1993-10-06 04:36:09 | D | 1994-05-16 06:45:20 | Z | 19188551
2000-01-04 15:57:01 | C | 2000-06-23 11:43:26 | W | 14759185
2010-05-16 06:45:20 | B | 2008-01-04 15:57:01 | Y | 74530099
2012-06-23 11:43:26 | A | 2008-01-04 15:57:01 | Y | 140989585
(5 rows)
Bryan
From | Date | Subject | |
---|---|---|---|
Next Message | Steve Crawford | 2012-07-26 20:06:50 | Re: Joining time fields? |
Previous Message | Oliveiros d'Azevedo Cristina | 2012-07-26 19:14:12 | Re: Joining time fields? |