ahmedrahil786

Amar number of Car - per car type

May 12th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. select
  2.  
  3.  
  4. count(distinct c.id) as carid,
  5. cc.car_name as carname
  6. #z.region as Region
  7.  
  8. from cars as c
  9.  
  10. join car_classes as cc
  11. on c.car_class_id = cc.id
  12.  
  13. join zones as z
  14. on z.id = c.zone_id
  15.  
  16. join car_zone_logs as cz
  17. on c.id = cz.car_id
  18.  
  19. where cz.car_state = 'Normal'
  20. and z.state = 'normal'
  21.  
  22. group by carname
Advertisement
Add Comment
Please, Sign In to add comment