MySQL查询问题

| 我有当前的数据库设置:
Forename | Surname | Department | Completion_Status
Tom        Smith     Sales        Started
Bob        Jones     Sales        Completed
Alison     Baines    Sales        Not Started
Arthur     Smith     Marketing    Started
Claire     Staines   Marketing    Completed
我能够返回没有问题的总行数以及完成状态为“已开始”或“已完成”但不在单个语句中的总数-但是,我想在单个语句中执行的操作是:
COUNT for Department As Total AND the COUNT for Department As Responses WHERE Completion_Status IN (\'Started\', \'Completed\')
它看起来像这样:
Department | Total | Responses
Sales        3       2
Marketing    2       2
希望有道理!? 谢谢荷马。     
已邀请:
select 
department,
count(department) as total,
sum(if(completion_status  IN (\'Started\', \'Completed\'),1,0)) as responses
from table
group by department
这是一个更标准的版本
select 
department,
count(department) as total,
sum(case when completion_status in (\'Started\', \'Completed\') then 1 else 0 end ) as responses
from table
group by department
    
SELECT部门 COUNT(部门),总计 COUNT(completion_status)个AS响应 来自Tresults WHEREcompletion_statusIN((\'已开始\',\'已完成\') GROUP BY部门 下订单     

要回复问题请先登录注册