count distinct groupby small record

 1 select * from t_um_user
 2 --2204
 3 select count(*) from t_um_user
 4 --2204
 5 
 6 select name from t_um_user --包含null
 7 --2204
 8 select count(name) from t_um_user --排除null(6个)
 9 --2198
10 
11 select distinct name from t_um_user --包含null
12 --1973 
13 is  SELECT  COUNT ( DISTINCT name) from t_um_user - negative null 
14  - 1972 
15  
16  SELECT name from t_um_user Group  by name
 . 17  - 1973 
18 is  SELECT name, COUNT (name) AS iCount from t_um_user Group  by name - name comprising null, but the count (name) does not contain a null 
. 19  - 1973 (name of the row is null, iCount = 0) 
20 is  SELECT name,COUNT ( * ) AS iCount from t_um_user Group  by name - name contains null 
21 is  - 1973 (name of the row is null, iCount =. 6) 
22 is  ================= ============================== 
23  - table t_user only name a field 
24-  the SELECT name from t_user
 25  - 2204 
26  the SELECT  COUNT (name) from t_user - exclude null 
27  - 2198 
28  the SELECT  COUNT ( * )from t_user - contain null
 29  - 2204 (although * looks equal name, but the calculated result is not the same)

 

Guess you like

Origin www.cnblogs.com/chenshao/p/12143724.html