Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select
- cc.car_name as carname,
- sum(TIMESTAMPDIFF(hour,CONVERT_TZ(r.start_at, '+00:00', '+8:00'),CONVERT_TZ(r.end_at, '+00:00', '+8:00'))) as ridelength
- from reservations r
- join cars c
- on c.id = r.car_id
- join car_classes cc
- on cc.id = c.car_class_id
- where CONVERT_TZ(r.start_at, '+00:00', '+8:00') >= '2019-1-1 00:00'
- and CONVERT_TZ(r.start_at, '+00:00', '+8:00') <= '2019-1-31 00:00'
- and r.state = 'completed'
- group by cc.car_name
Advertisement
Add Comment
Please, Sign In to add comment