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)
會做到這一點。