select c_id from score group by s_id having count(*)>1;
結果中有重復值,然后我加個distinct 后結果為空。
select distinct c_id from score group by s_id having count(s_id)>=1;
為什么呢,執行順序不是from,where,group by,having,select ,distinct嗎?
是不是distinct跟 group by不能一起這么用,百度了好久都沒有答案,希望有人幫我一下。
我知道這么寫沒什么意義,主要重點就是問問distinct是不是和group by不能這么用?
uj5u.com熱心網友回復:
SELECT 要在GROUP BY 應該是欄位錯select c_id from score group by s_id having count(*)>1;
uj5u.com熱心網友回復:
count(s_id)--s_id值為NULL是不計算的count(*)--都會計算
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/139174.html
標籤:基礎類
上一篇:買不到的數目[藍橋杯]
