Mysql 如果所有分组行均为1,则显示1,否则显示0

Mysql 如果所有分组行均为1,则显示1,否则显示0,mysql,select,group-by,Mysql,Select,Group By,我有一个疑问: select *, sum(services.amount) as service_amount from invoices left join projects using(project_id) left join services using(invoice_id) where client_id = ? group by project_id order by issue_date desc 在表invoices中,我有一列paid,它是tinyint,即1或0 再加上

我有一个疑问:

select *, sum(services.amount) as service_amount from invoices
left join projects using(project_id)
left join services using(invoice_id)
where client_id = ?
group by project_id
order by issue_date desc
在表
invoices
中,我有一列
paid
,它是
tinyint
,即
1
0


再加上我的查询,如果所有分组的
paid
列行都相等
1
,我如何才能使返回的
paid
列显示
1
,否则
paid
列显示
0

我认为您可以使用sql中的min关键字。比如:

select MIN(paid), sum(services.amount) as service_amount from invoices
left join projects using(project_id)
left join services using(invoice_id)
where client_id = ?
group by project_id
order by issue_date desc

我认为您可以在sql中使用min关键字。比如:

select MIN(paid), sum(services.amount) as service_amount from invoices
left join projects using(project_id)
left join services using(invoice_id)
where client_id = ?
group by project_id
order by issue_date desc
选择min(付费)可能吗?如果有0,则应为0,否则为1。

选择最小值(付费)可能吗?如果存在0,则应为0,否则为1