我只需要下面添加每个计数的总计,这对我不起作用,我得到"关键字附近的语法错误' SELECT'。":
DECLARE @total int
SET @total = Count(some select statement)
@total = @total + Count(some select statement)
@total = @total + Count(some select statement)
@total = @total + Count(some select statement)
.. and so on
-- now return the grand total
select @total
或者如果您认为有更简单或更有效的方式来做到这一点,我也是全心全意。
答案 0 :(得分:0)
declare @total int = 0
select @total += count(*) from (select 1 col1) a
select @total += count(*) from (select 1 col1) a
select @total += count(*) from (select 1 col1) a
select @total