2016-07-31 85 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>')) 
相關問題