Re: Joining time fields?
От | Bryan Lee Nuse |
---|---|
Тема | Re: Joining time fields? |
Дата | |
Msg-id | E04ACAA2-35E8-4919-AB3A-8D2E47F2F1A4@uga.edu обсуждение исходный текст |
Ответ на | Re: Joining time fields? ("Oliveiros d'Azevedo Cristina" <oliveiros.cristina@asperger-talents.com>) |
Список | 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
В списке pgsql-novice по дате отправления: