【发布时间】:2020-11-03 10:50:15
【问题描述】:
我需要帮助。
我有sql代码:
SELECT app_users.name,COUNT(owner)
FROM app_users
INNER JOIN app_tickets
ON app_tickets.owner = app_users.id
where app_tickets.status IN (0,1,2,4,5)
GROUP BY app_users.name
此代码显示如下值:
Adam Smith 12
Brad Smith 23
Nancy Smith 3
但我需要像这样展示价值
Adam Smith 12
Ann Smith 0
Brad Smith 23
Nancy Smith 3
Peter Smith 0
我尝试使用 IFNULL() 和 COALESCE() 但没有帮助
【问题讨论】:
标签: mysql sql count subquery left-join