Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select A.month as month, A.year as year, ifnull(A.amount,0) as Fuel_card_amount, ifnull(B.Amount,0) as petrol_reimbursement ,
- ifnull(A.amount,0)+ifnull(B.Amount,0) as total_fuel_Cost
- from
- (select
- month(fu.created_at + interval 8 hour) as month,
- year(fu.created_at + interval 8 hour) as year,
- ifnull(sum(fu.amount),0) as amount
- from fuel_card_uses fu
- group by 1,2 ) A
- left join
- (select
- month(fr.created_at + interval 8 hour) as month,
- year(fr.created_at + interval 8 hour) as year,
- ifnull(sum(fr.requested_amount),0) as amount
- from fuel_reimbursements fr
- group by 1,2 ) B
- on A.month = B.month and A.year = B.year
- group by 1,2
- order by 2 asc,1 asc
Advertisement
Add Comment
Please, Sign In to add comment