下面count的返回值是多少?sql
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;
答案ide
--Query1:4 --Query2:4 --Query3:ERROR
參考連接:https://technet.microsoft.com/en-us/library/ms175997(v=sql.90).aspxspa