2016-07-31 89 views

回答

1

对于常规的数量,不包括列名:

count(*) 

对于数不同,只需要添加额外的价值回:

count(distinct a4) + (case when count(a4) <> count(*) then 1 else 0 end) 

这可以在MySQL中简化为:

count(distinct a4) + (count(a4) <> count(*)) 

或者,如果您知道列中不存在价值:

count(distinct coalesce(a4, ' <NULL>')) 
相关问题