注册 登录
编程论坛 SQL Server论坛

请教怎么把这两句的结果合在一个表格内?

wube 发布于 2019-01-23 13:44, 2129 次点击
SELECT A.CateMainName, COUNT(B.ProjectNo) AS ProjCnt FROM [tblProject] As B INNER JOIN [tblBasCategory] As A
On A.CateMainID = 3 and B.CateMainID =3 and A.CateSubID=B.CateSubID and B.ReleaseDate is NULL GROUP BY A.CateMainID,A.CateMainName order by A.CateMainID
结果 :
CateMainName ProjCnt
Improve         66

SELECT A.CateMainName, COUNT(B.ProjectNo) AS ProjCnt FROM [tblProject] As B INNER JOIN [tblBasCategory] As A
On A.CateMainID =3 and B.CateMainID =3 and A.CateSubID=B.CateSubID and B.ReleaseDate is not NULL GROUP BY A.CateMainID,A.CateMainName order by A.CateMainID
结果 :
CateMainName ProjCnt
Improve         5

目标 :
CateMainName ProjCnt
Improve         66
Improve         5
2 回复
#2
wube2019-01-23 15:09
有人教了,又学到一招,用UNION
#3
wube2019-01-23 19:37
又学到了用left JOIN可以使COUNT(*)显示搜寻结果为0的值
1