比如 下面的語句 , 用於分組統計
select count(*) from es_diabetes where uid=43658 GROUP BY uniques
結果明顯不是我們想要得,為什么呢,因為這是個group up分組
改為下面的,先去重 , 再分組
select count(DISTINCT uniques ) from es_diabetes where uid=43658
group by 是分組,不能直接用於 count 統計
但是select還是可以的
或者 可以使用 子查詢
SELECT count(*) AS c FROM(SELECT count(*) FROM es_diabetes where uid =43658 GROUP BY uniques ) as s
結果還是一樣的