我想在一张表中计算不同的条件:
SELECT gt.smechanic as 'Mech ID',
gm.mechanic_name as 'Mech Name',
count(gt.smechanic) as 'Total Invoices Not Received',
count(if(datediff(gt.dispatch_date, curdate()) < 10,1,0)) as 'Within 10 days'
from gt
straight_join gm on gt.smechanic = gm.mechanic_id
where gt.status = 3 or gt.status = 5
group by gt.scheduled_mechanic
我不确定我是否用这个语句取消了自己,因为在我计算的两列中返回了相同的值。