Re: Getting the count(*) from two tables and two date ranges in same query
От | Håkan Jacobsson |
---|---|
Тема | Re: Getting the count(*) from two tables and two date ranges in same query |
Дата | |
Msg-id | 5580CB5EB883C44587BC48FA0E54592223E4E14AB2@RTSRV02.relevanttraffic.local обсуждение исходный текст |
Ответ на | Re: 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 |
Adam, I just realised that issuing the SQL on one table produces the correct count. SELECT sum(case when table2.date between '2007-07-13' and '2007-07-13' then 1 else 0 end) as sumx FROM table2 WHERE id = n; This is working alright. So the problem should lie in the last part: from table2, table3 where table2.id = table3.id and table2.id = n; I think I need the UNION statement instead? Håkan Jacobsson - System Developer ---------------------------------------------------------------- RELEVANT TRAFFIC EUROPE AB, Riddarg 17D, SE-114 57 Sthlm, Sweden Mobile (+46) 736 56 97 58 Direct (+46) 8 56 24 98 05 Phone to office (+46) 8 678 97 50 || Fax (+46) 8 661 19 22
В списке pgsql-general по дате отправления: