I've got two tables that I need a count on both of them.
table1: idtable2: cid (table1.id = table2.cid) -- Join can be done by this.
I already got two queries that I'm using, and wanna put them in one single query.
Query related to table1
:
WITH c_status AS (select CASE WHEN regdate = 1 THEN 'yes' WHEN regdate = 2 THEN 'no' from table1 end as status_1)select status_1, count(*) AS c_status_count from c_status group by status_1
OUTPUT:
yes 548no 2269
Query related to table2
:
WITH u_status AS (select CASE WHEN regdate = 1 THEN 'yes' WHEN regdate = 2 THEN 'no' from table2 end as status_2)select status_2, count(*) AS u_status_count from u_status group by status_2
OUTPUT:
yes 564256no 31452345234
Question:
How can I put those two queries together? I want one single query reporting both counts.
UPDATE: Desired output:
u_status yes 548u_status no 2269c_status yes 564256c_status no 31452345234