感谢所有让我走到这一步的人!以下工作,但我无法弄清楚如何返回超过 1 行,包括所有当前列名。我了解该语句当前的编写方式,它应该只返回一行。但是,我尝试了几个子查询示例,但我的总和列似乎总是被排除在结果之外。任何帮助都会很棒,谢谢。
SELECT
club.id,
club.name,
club.status,
users.firstname,
users.lastname,
users.rights,
SUM( job.status > '0' ) AS total,
SUM( job.status = '1' ) AS incomplete,
SUM( job.status = '2' ) AS pending,
SUM( job.status = '3' ) AS live,
SUM( job.status = '4' ) AS closed
FROM club
LEFT JOIN surveys
ON job.club_id = club.id
LEFT JOIN users
ON users.id = job.users_id
WHERE job.status > 0