Re: Having the sum of two queries
От | Hélder M. Vieira |
---|---|
Тема | Re: Having the sum of two queries |
Дата | |
Msg-id | 001401c7c7f4$c4515280$6200a8c0@hmv02 обсуждение исходный текст |
Ответ на | Having the sum of two queries (Dani Castaños <danitao.mailists@gmail.com>) |
Ответы |
Re: Having the sum of two queries
|
Список | pgsql-sql |
>... SELECT tot.status, COUNT(total) > FROM( QUERY A UNION QUERY B ) AS tot > GROUP BY tot.status > > But it doesn't works. It doesn't add the total columns with the same > status... >... I guess you have two problems, if I understand what you're trying to do. - As Roberto Spier noted, 'sum' would be better than 'count' in the outer query. - Also, 'union' will silently remove duplicate rows, unless you use 'union all'. Please check if this is what you want: select status, count(status) from ( select status from users union all select status from imported_users ) as fff group by status; Regards, ´ Helder M. Vieira
В списке pgsql-sql по дате отправления: