ahmedrahil786

number of cars per week and month

May 13th, 2019
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. select
  2. WEEKOFYEAR(czl.log_date + interval '8' hour) as Week,
  3. count(distinct czl.id)/7 as cars
  4.  
  5. from car_zone_logs czl
  6. where czl.log_date + interval '8' hour >= @start
  7. and czl.car_state = 'normal'
  8. and czl.zone_state = 'normal'
  9.  
  10. group by 1 ;
  11.  
  12. select
  13. MONTH(czl.log_date + interval '8' hour) as Week,
  14. count(distinct czl.id)/30 as cars
  15.  
  16. from car_zone_logs czl
  17. where czl.log_date + interval '8' hour >= @start
  18. and czl.car_state = 'normal'
  19. and czl.zone_state = 'normal'
  20.  
  21. group by 1 ;
Advertisement
Add Comment
Please, Sign In to add comment