SELECT COUNT(A.ID)
FROM New_ByLaw_Public_Infor A INNER JOIN
New_ByLaw_Paper B ON A.NewByLawCode = B.NewByLawCode
union allselect count(ID) from New_ByLaw_Public_Infor A where UserCode=2;
FROM New_ByLaw_Public_Infor A INNER JOIN
New_ByLaw_Paper B ON A.NewByLawCode = B.NewByLawCode
union allselect count(ID) from New_ByLaw_Public_Infor A where UserCode=2;
FROM New_ByLaw_Public_Infor A INNER JOIN
New_ByLaw_Paper B ON A.NewByLawCode = B.NewByLawCode
UNION ALL
select count(ID) from New_ByLaw_Public_Infor A where UserCode=2;
FROM New_ByLaw_Public_Infor A INNER JOIN
New_ByLaw_Paper B ON A.NewByLawCode = B.NewByLawCode
union allselect count(ID)ID from New_ByLaw_Public_Infor A where UserCode=2;
FROM New_ByLaw_Public_Infor A INNER JOIN
New_ByLaw_Paper B ON A.NewByLawCode = B.NewByLawCode;
union all as cnt
select count(ID) from New_ByLaw_Public_Infor A where UserCode=2;
FROM New_ByLaw_Public_Infor A INNER JOIN
New_ByLaw_Paper B ON A.NewByLawCode = B.NewByLawCode;
union
select count(ID) from New_ByLaw_Public_Infor A where UserCode=2;
FROM New_ByLaw_Public_Infor A INNER JOIN
New_ByLaw_Paper B ON A.NewByLawCode = B.NewByLawCode;
union all as cnt , '0' as flag
select count(ID) from New_ByLaw_Public_Infor A where UserCode=2;
到时候用 flag区分 你想要得结果。
union 合并所有项包括相同的