我呼籲個人5張桌子,dailypay,獎金,欠條和貸款想寫一個查詢,將生成工資該表的......我的代碼是與MySQL的問題JOIN語句
select personal.name as NAME,
(sum(dailypay.pay) + bonuses) - (iou.amount + loans.monthly_due)) as SALARY
from personal
join dailypay on personal.eid = dailypay.eid
left join bonuses on personal.eid = bonuses.eid
left join iou on personal.eid = iou.eid
left join where dailypay.date = 'specified_date'
and bonuses.date_approved = 'specified_date'
and iou.date_approved = 'specified_date'
and loans.date = month(now()
它返回確實有紅利,iou和貸款記錄的員工的姓名和空薪水值。但我想總結他們的日常支付,扣除/增加扣除額或返回值,在沒有記錄的情況下,它應該繼續進行總和而沒有任何扣減。
問題解決了,謝謝一堆。你搖滾。 – code4 2012-01-30 11:34:27