Re: GROUP BY on a column which might exist in one of two tables

Поиск
Список
Период
Сортировка
От Mark Stosberg
Тема Re: GROUP BY on a column which might exist in one of two tables
Дата
Msg-id 1214403475.30599.45.camel@localhost
обсуждение исходный текст
Ответ на Re: GROUP BY on a column which might exist in one of two tables  (hubert depesz lubaczewski <depesz@depesz.com>)
Список pgsql-sql
> select
>     coalesce(h.partner_id, v.partner_id) as partner_id,
>     coalesce(v.count, 0) as total_views,
>     coalesce(h.count, 0) as total_hits
> from
>     (select partner_id, count(*) from hits group by partner_id) as h
>     full outer join
>     (select partner_id, count(*) from views group by partner_id) as v
>     on h.partner_id = v.partner_id
> ;
> 

That looks right. Thanks!




В списке pgsql-sql по дате отправления:

Предыдущее
От: hubert depesz lubaczewski
Дата:
Сообщение: Re: GROUP BY on a column which might exist in one of two tables
Следующее
От: "Greg Sabino Mullane"
Дата:
Сообщение: Re: GROUP BY on a column which might exist in one of two tables