0
看看下面的例子计数()的不同值
CREATE TABLE #repeated (iValue int NOT NULL)
INSERT INTO #repeated
VALUES(1),(1),(2),(3),(4),(5),(5),(5),(6),(7)
SELECT * FROM #repeated
SELECT
count(*) as countAsterisco
,count(iValue) as countValue
FROM #repeated
两个countAsterisco和countValue结果在10,因为这两个方面考虑重复值。我只需要计算不同的值,所以结果必须是7.
是否有这样的功能?我认为count(iValue)
会做到这一点。