sql - 最大子查询
问题描述
select substr(phone,0,3) as area_code
from customer
where (select max(count(area_code))
from customer);
为什么这里有错误?怎么修?它说缺少表达..
解决方案
整个select max() ...
部分返回一个值,但在where
clausule 之后你应该有类似where something = 1
. 我只能猜测你想用这个查询实现什么,但它可能应该是这样的:
select substr(phone,0,3) as area_code from customer
where area_code in (select max(substr(phone,0,3)) from customer);
PS看这里
推荐阅读
- cmd - 如何使用-tree在目录中显示一层文件夹?
- html - Django:获取 FormField 的下拉值
- apache-kafka - Confluent Rest Proxy Schem 注册表在发送缺少的属性键时不会引发错误
- bash - 在 bash 脚本中使用 find exec 时如何随机命名文件?
- excel - 我在 2 个电子表格中使用 vlookup。公式似乎是正确的,但没有返回值,只显示公式
- ios - UIImagePickerController 和 UINavigationControllerDelegate 实现
- amazon-cloudwatch - AWS Cloudwatch Logs Insights 查找接近另一个日志或时间戳的日志
- android - 位图无法在线性布局中正确加载
- angular - 重新实例化数据时,Angular CDK 拖放列表会中断
- java - 强制客户端或服务器重新启动 SSL 握手(或使 SSL 会话过期)