| От | Mark Stosberg |
|---|---|
| Тема | GROUP BY on a column which might exist in one of two tables |
| Дата | |
| Msg-id | 1214401817.30599.40.camel@localhost обсуждение исходный текст |
| Ответы |
Re: GROUP BY on a column which might exist in one of two
tables
Re: GROUP BY on a column which might exist in one of two tables |
| Список | pgsql-sql |
Hello,
I could use some help figuring out a complex "GROUP BY".
As a setup, let's say I have two tables which stores a single "hit" or
"view" in a row
hits hit_id partner_id
views view_id partner_id
There is of course a "partners" table with a "partner_id" column.
My target result is more like
partner_id
total_views
total_hits
Where the totals are "counts" of the the rows in the hits and views
tables. There should be no rows for partners without hits or views.
My first attempt at the SQL for this GROUP
COALESCE(hits.partner_id,views.partner_id) which didn't work.
I'm stuck on what to try next.
Thanks!
Mark
В списке pgsql-sql по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера