Advertisement
ahmedrahil786

Number of cars per week Rahil _ doubt to find cumulative inc

May 27th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. set @start := '2018-12-31 00:00';
  2.  
  3. select
  4. Date(date_sub(czl.log_date , interval 1 day)) as week,
  5. weekday(date_sub(czl.log_date , interval 1 day)) as weekday,
  6. count(distinct czl.car_id ) as ncars
  7. from car_zone_logs czl
  8. where czl.log_date + interval '8' hour >= @start
  9. and czl.car_state = 'normal'
  10. and czl.zone_state = 'normal'
  11. and czl.csa_state = 'normal'
  12. and weekday(date_sub(czl.log_date , interval 1 day)) = 6
  13. group by 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement