标题:请教怎么把这两句的结果合在一个表格内?
只看楼主
wube
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:23
帖 子:1817
专家分:3681
注 册:2011-3-24
结帖率:98.24%
 问题点数:0 回复次数:2 
请教怎么把这两句的结果合在一个表格内?
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
搜索更多相关主题的帖子: 结果 表格 and NULL order 
2019-01-23 13:44
wube
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:23
帖 子:1817
专家分:3681
注 册:2011-3-24
得分:0 
有人教了,又学到一招,用UNION

不要選我當版主
2019-01-23 15:09
wube
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:23
帖 子:1817
专家分:3681
注 册:2011-3-24
得分:0 
又学到了用left JOIN可以使COUNT(*)显示搜寻结果为0的值

不要選我當版主
2019-01-23 19:37



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-492807-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.145358 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved