测试一下你的T-SQL基础知识-count
下面count的返回值是多少?
CREATE TABLE mytable ( myid INT, mychar VARCHAR(10) ); GO INSERT mytable ( myid, mychar ) VALUES ( 1, 'A' ), ( 2 , 'B'), ( NULL, 'C' ), ( 4, 'D' ), ( NULL, 'E' ), ( 6, 'F' ); --Query1 SELECT COUNT(MyID) FROM mytable; --Query2 SELECT COUNT( DISTINCT MyID) FROM mytable;
--Query3
SELECT COUNT(DISTINCT *) FROM mytable;
答案
--Query1:4 --Query2:4 --Query3:ERROR
参考链接:https://technet.microsoft.com/en-us/library/ms175997(v=sql.90).aspx