close
在fb看到一題有趣的sql題
記錄下來
幾位大大提出
SELECT * FROM Girl WHERE Girl.ID NOT IN (SELECT DISTINCT(GirlID) FROM Girl_Criteria WHERE CriterialID NOT IN (2, 3, 5))
版大則是提出效能更好的
Triton Ho社團管理員 select girl_id from (
select girl_id, sum(case when criteria_id in (2, 3, 5) then 1 else 0 end) as matched, count(1) as total
from girl_criteria
group by girl_id
) t
where t.matched = t.total
太強了,又學到一課
全站熱搜