Re: Getting the count(*) from two tables and two date ranges in same query
В списке pgsql-general по дате отправления:
| От | Adam Rich |
|---|---|
| Тема | Re: Getting the count(*) from two tables and two date ranges in same query |
| Дата | |
| Msg-id | 020b01c861b9$345467d0$9cfd3770$@r@sbcglobal.net обсуждение исходный текст |
| Ответ на | Getting the count(*) from two tables and two date ranges in same query (Håkan Jacobsson <hakan.jacobsson@relevanttraffic.com>) |
| Ответы |
Re: Getting the count(*) from two tables and two date ranges
in same query
Re: Getting the count(*) from two tables and two date ranges in same query |
| Список | pgsql-general |
> Resulting in 4 columns in the ResultSet like: > > count(*)_from_table2_between_fromdate1_and_todate1 = X > count(*)_from_table2_between_fromdate2_and_todate2 = Y > count(*)_from_table3_between_fromdate1_and_todate1 = Z > count(*)_from_table3_between_fromdate2_and_todate2 = V > > Is this possible? Select t1.id, sum(case when t2.date between d1 and d2 then 1 else 0 end) as sum1, sum(case when t3.date between d1 and d2 then 1 else 0 end) as sum2 from t1, t2, t3 where t1.id=t2.id and t2.id = t3.id group by t1.id
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера