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