这里要查询的是去过的国家数(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;

 

相关文章:

  • 2022-12-23
  • 2021-10-05
  • 2022-12-23
  • 2021-06-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-19
  • 2021-12-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-10
  • 2021-07-06
相关资源
相似解决方案