【发布时间】:2020-05-28 19:42:11
【问题描述】:
我的代码是这样的,但给出了错误,不知道为什么。请帮忙!
select city,
min(length(city))
from station
group by length(city)=min(length(city))
order by city asc;
【问题讨论】:
-
而错误是...?
-
错误是:组函数的使用无效
-
也许可以解释一下你想用那个 group by 语句来完成什么?看起来您正在混淆 GROUP BY 和 WHERE 语句
-
感谢您的见解我终于得到了正确的代码:select city, min(length(city)) as minimum from station group by city order by minimum asc limit 1 ;
标签: mysql sql select sql-order-by greatest-n-per-group