当前位置: 代码迷 >> Sql Server >> 怎么使用一条sql语句统计行数
  详细解决方案

怎么使用一条sql语句统计行数

热度:71   发布时间:2016-04-24 21:12:57.0
如何使用一条sql语句统计行数
本来我是这么写的,自己感觉也不满意 

declare @rowCount int,@rowCount1 int ,@rowCount2 int
set @rowCount=0
select @rowCount1=count(*) from elecpolicy where epprodsn = ''
select @rowCount2=count(*) from SonyPolicyRecommend where epprodsn = ''
set @rowCount=@rowCount1+@rowCount2
select @rowCount

能不能有一种办法 ,  一条sql查询出结果?

------解决方案--------------------
select (select count(*) from elecpolicy where epprodsn = '')+(select count(*) from SonyPolicyRecommend where epprodsn = '')
  相关解决方案