我的查询看起来像:
select distinct col1,col2,col3,col4
from tab1;
当我执行上述语句时,如何获取将作为输出的行数?...或如何添加count()
到上述声明?
我的查询看起来像:
select distinct col1,col2,col3,col4
from tab1;
当我执行上述语句时,如何获取将作为输出的行数?...或如何添加count()
到上述声明?
@@ROWCOUNT
返回您需要的...
示例用法:
declare @resultCount AS INT
select distinct col1,col2,col3,col4
from tab1;
SELECT @resultCount=@@ROWCOUNT
PRINT @resultCount
SELECT COUNT(DISTINCT col1,col2,col3,col4) FROM tabl
;with cte as (
select distinct col1,col2,col3,col4 from tab1
)
select count(1) from cte