История изменений
Исправление
Legioner,
(текущая версия)
:
select '' as org_id, 1 as "1", 2 as "2", 3 as "3"
union all
(select distinct org_id::text as "org_id",
(select count(*) from test where org_id = t.org_id and post_id = 1) as "1",
(select count(*) from test where org_id = t.org_id and post_id = 2) as "2",
(select count(*) from test where org_id = t.org_id and post_id = 3) as "3"
from test t
order by org_id)
Исходная версия
Legioner,
:
select '' as org_id, 1 as "1", 2 as "2", 3 as "3"
union all
(select distinct org_id::text as "org_id",
(select count(*) from test where org_id = t.org_id and post_id = 1) as "1",
(select count(*) from test where org_id = t.org_id and post_id = 1) as "2",
(select count(*) from test where org_id = t.org_id and post_id = 1) as "3"
from test t
order by org_id)