2
我想在一個表來計算不同的條件:MySQL的計數如果DateDiff的
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
我不知道如果我取消自己離開這個說法,因爲我指望相同的值既是列回。
請與您的查詢共享問題。 –