Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT concat(year(created_at), "_", month(created_at)) AS "Workshop_Out Month",
- count(id) AS "accidents out",
- count(DISTINCT car_id) AS "cars out",
- sum(quotation_amount) AS "repair cost",
- sum(member_charged_amount) AS "charged amount",
- format(100*sum(member_paid_amount)/sum(member_charged_amount),0) AS "Member paid percentage",
- avg(quotation_amount) AS "repair cost per accident",
- sum(quotation_amount)/count(DISTINCT car_id) AS "repair cost per car",
- 100 as "100% Collection"
- FROM car_accidents
- WHERE is_insurance=0
- AND state="completed"
- GROUP BY year(created_at),
- month(created_at)
Advertisement
Add Comment
Please, Sign In to add comment