Parent Table ID Flag1 Flag2 1 1 1 2 NULL 1 3 1 1 Child Table ID acc Category 1 101 Cate1 1 102 Cate5 2 103 Cate2 2 104 Cate3 3 105 Cate4 3 106 Cate4
select count(1) from Parent A,Child B where A.ID=B.ID AND B.Category='CATE1' and A.Flag1=1
Category Flag1_Count Flag2_Count Cate1 1 0 Cate2 0 1 Cate3 1 1
SELECT B.Category, Count(A.Flag1) AS Flag1_Count, Count(A.Flag2) AS Flag2_Count FROM Parent A INNER JOIN Child B WHERE A.ID=B.ID GROUP BY B.Category;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)