我有这个查询:
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
是 a tinyint
that is 1
or 0
。
添加到我的查询中,如果所有分组的列行都相等,如何使返回paid
列显示,否则显示该列?1
paid
1
0
paid