ahmedrahil786

Repair Cost - Rahil

May 19th, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. SELECT concat(year(created_at), "_", month(created_at)) AS "Workshop_Out Month",
  2. count(id) AS "accidents out",
  3. count(DISTINCT car_id) AS "cars out",
  4. sum(quotation_amount) AS "repair cost",
  5. sum(member_charged_amount) AS "charged amount",
  6. format(100*sum(member_paid_amount)/sum(member_charged_amount),0) AS "Member paid percentage",
  7. avg(quotation_amount) AS "repair cost per accident",
  8. sum(quotation_amount)/count(DISTINCT car_id) AS "repair cost per car",
  9. 100 as "100% Collection"
  10.  
  11. FROM car_accidents
  12. WHERE is_insurance=0
  13. AND state="completed"
  14. GROUP BY year(created_at),
  15. month(created_at)
Advertisement
Add Comment
Please, Sign In to add comment