Trying to get count of distinct rows in one query and in one row
table 1..
ID name
1 a
2 b
3 c
Table 2
ID Parent status
1 1 0
2 1 1
3 1 0
4 1 0
5 1 2
6 2 0
desired result (count of distinct child elements)
ID name 0a 1s 2s
1 a 3(count of 0s) 1 (counts of 1s) 2 (count of 2s)
Can we get this in one query..
What I have tried is result me values in 3 rows
Select t1.id, t1.name, count(status) from TABLE_1 t1 Left JOIN TABLE_2 t2
ON t1.id = t2.parent
group by status
ID name status
1 a 3
1 a 1
1 a 1
2 b 1