I have two tables with a column id and a flag. I want to get in one line the number of rows, where table2.id = some condition; With this request:
select table1.ID, table1.FLAG, count(1) row_count
from table1,
table2
where table1.ID = 123
and table1.ID = table2.ID
group by table1.ID, table1.FLAG, table2.FLAG
if table2.FLAG has 3 different values (Active, Suspend, Other), then I have 3 rows, the question is how to combine these three rows into one something like this: ID,FLAG,Active_Count,Suspend_Count,Other_Count.