Having the sum of two queries

Поиск
Список
Период
Сортировка
От Dani Castaños
Тема Having the sum of two queries
Дата
Msg-id 469B512D.70507@gmail.com
обсуждение исходный текст
Ответы Re: Having the sum of two queries  (Achilleas Mantzios <achill@matrix.gatewaynet.com>)
Re: Having the sum of two queries  (Roberto Spier <roberto.spier@conab.gov.br>)
Список pgsql-sql
Hi all!

I want to do something like this:

SELECT status, COUNT( status ) AS total
FROM users
GROUP BY status

UNION

SELECT status, COUNT(status) AS total
FROM imported_users
GROUP BY status


And have the result of both added.

I've tried something like

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...


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

Предыдущее
От: chester c young
Дата:
Сообщение: Re: data dependent sequences?
Следующее
От: Achilleas Mantzios
Дата:
Сообщение: Re: Having the sum of two queries