我的查询如下:
select distinct col1,col2,col3,col4
from tab1;
当我执行上述语句时,如何获得将作为输出的行数? ...或如何将count()
添加到上述声明中?
答案 0 :(得分:0)
;with cte as (
select distinct col1,col2,col3,col4 from tab1
)
select count(1) from cte
答案 1 :(得分:0)
@@ROWCOUNT
会返回您需要的内容......
使用示例:
declare @resultCount AS INT
select distinct col1,col2,col3,col4
from tab1;
SELECT @resultCount=@@ROWCOUNT
PRINT @resultCount
答案 2 :(得分:0)
SELECT COUNT(DISTINCT col1,col2,col3,col4) FROM tabl