ahmedrahil786

Number of cars by City and Car type

Apr 2nd, 2020
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. select month(czl.log_date + interval 8 hour) as month,
  2. Year(czl.log_date + interval 8 hour) as year,
  3. z.city as city,
  4. cc.car_name as carname,
  5. count(distinct czl.car_id) as ncars
  6. from car_zone_logs czl left join cars c on czl.car_id = c.id
  7. left join car_classes cc on c.car_class_id = cc.id
  8. left join zones z on c.zone_id = z.id
  9. where year(czl.log_date + interval 8 hour) = '2020'
  10. and month(czl.log_date + interval 8 hour) = '4'
  11. and date(czl.log_date + interval 8 hour) = date_sub(CURDATE(), interval 1 day)
  12. and z.city in ('KL','PG','JB','SL')
  13. and czl.zone_state = 'normal'
  14. and c.state = 'normal'
  15. group by 1,2,3,4
Advertisement
Add Comment
Please, Sign In to add comment