這里要查詢的是去過的國家數(country)的次數ct大於2的人的名字
select name ,count(country) ct from sz03 where ct >2 group by name;
ERROR 1054 (42S22): Unknown column 'ct' in 'where clause'
第一次看到一個和這個類似的sql時,並沒有發現這樣寫是錯誤的,直到自己也寫了一個錯誤的才想起來。
select name ,ct from (select name ,count(country) ct from sz03 group by name )as tt where ct =2;
