數據完整性是任何數據庫系統要保證的重點
用COUNT(*)處理空值
大多數集合函數都能在計算時消除空值
如果希望COUNT函數對給定列的所有行(包括空值)進行計數
事實上
SET NOCOUNT ON
GO
CREATE TABLE xCount
(pkey
CONSTRAINT pk_xCount PRIMARY KEY
Col
GO
INSERT xCount (Col
GO
INSERT xCount (Col
GO
INSERT xCount (Col
GO
INSERT xCount (Col
GO
SELECT AVG(Col
AVG(ISNULL(Col
COUNT(Col
COUNT(ISNULL(Col
Count(*) UsingAsterisk
FROM xCount
GO
DROP TABLE xCount
GO
OUTPUT:
From:http://tw.wingwit.com/Article/program/SQLServer/201311/22244.html