sql - MySQL LEFT JOIN 与 GROUP BY 和 WHERE 子句查询
解决方案
您可以使用left join
和聚合:
select d.name, count(e.id)
from departments d left join
employees e
on e.department_id = d.id and e.salary >= 10000
group by d.name
推荐阅读
- templates - UWP:如何为模板化控件设置命名空间
- python - 如何在循环中定义 Tkinter 检查按钮?
- discord.py - 创建一个响应多个嵌入字段的不和谐机器人命令
- angular-cli - 为什么我得到未知选项:'--output-hashing' angular 9
- ios - 在 iOS 中使用 AVPlayerViewController 的 Seekbar 可见性回调
- loops - 我可以在不使用“break”或不使用设置为“true”的变量的情况下退出循环吗
- jupyter-notebook - 如何直接在 Google Colab 上打开本地 Jupyter Notebook,而无需将其上传到 Google Drive 的额外步骤?
- sql - 提取日期直接小于感兴趣日期的所有行
- sqlite - 使用 System.Data.Sqlite 创建的 Microsoft.Data.Sqlite 打开加密的 Sqlite 数据库
- java - 为什么Java HashMap可以使用chaining时需要增加或减少