ahmedrahil786

Query Not working Checklo

Apr 5th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. select
  2. distinct m.id as memberid,
  3. co.comment as comment,
  4. sum(p.amount) as amount,
  5. date(r.occupy_start_at + interval '8' hour) as day,
  6. timestampdiff(minute,r.start_at, r.end_at)/60 as ridelength,
  7. TIMESTAMPDIFF(minute,r.start_at + interval '8' hour,r.end_at + interval '8' hour) as ridelengthinminutes,
  8. weekday(r.occupy_start_at + interval '8' hour) as startingday,
  9. hour(r.occupy_start_at + interval '8' hour) as startingtime,
  10. r.state as state,
  11. r.car_id as carid
  12.  
  13. from members m
  14.  
  15. left outer join reservations r
  16. on m.id = r.member_id
  17.  
  18. left outer join payments p
  19. on p.reservation_id = r.id
  20.  
  21. left outer join coupons co
  22. on co.member_id = m.id
  23.  
  24. where CONVERT_TZ(r.start_at, '+00:00', '+8:00') >= '2019-3-1 00:00'
  25. and CONVERT_TZ(r.start_at, '+00:00', '+8:00') < '2019-5-1'
  26. and m.imaginary = 'normal'
  27. and m.state = 'normal'
  28. and r.state IN ('completed','inuse','reserved')
  29. and p.state = 'normal'
  30. and p.paid_type = 'card'
  31.  
  32. group by m.id,r.id
  33. order by amount desc
Advertisement
Add Comment
Please, Sign In to add comment