本文介绍了如何在结果集表中获取两个计数列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我写sql查询时很差,请帮我把两列作为结果集如 OpenIssues ClosedIssues 50 1 通过以下查询但我得到的行如 OpenIssues 50 1 查询为如下: 选择 COUNT(*) as OpenIssues 来自 HX_Issue 其中​​ ProjectId = 1 和 ComponentId = 13 和 CreatedOn ' 2012/12/24' 和 ' 2013/01/30' 和 StatusId!= 23 union all 选择 COUNT(*) 关闭来自 HX_Issue 其中 ProjectId = 1 和 ComponentId = 13 和 CreatedOn ' 2012/12/24' 和 ' 2013/01/30' 和 StatusId = 23 解决方案 Hi,I am very poor in writing sql queryies please help me to get two columns as a result set likeOpenIssues ClosedIssues 50 1By the following query but i am getting in rows likeOpenIssues501The query as follows :select COUNT(*) as OpenIssues from HX_Issue where ProjectId=1 and ComponentId=13 and CreatedOn between '2012/12/24' and '2013/01/30' and StatusId !=23union allselect COUNT(*) as closed from HX_Issue where ProjectId=1 and ComponentId=13 and CreatedOn between '2012/12/24' and '2013/01/30' and StatusId =23 解决方案 这篇关于如何在结果集表中获取两个计数列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-18 10:27
查看更多