ahmedrahil786

One way - Proper MFT Split - Rahil V2.0

Jul 4th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. select FB.rid2 as rid, FB.mid, FB.way, FB.date from
  2. (select r.id as rid2 ,r.start_zone_id as stid, r.end_zone_id as edid,
  3. date(r.start_at + interval '8' hour) as date,
  4. fbo.mid as mid,fbo.rid,fbo.way as way from
  5. reservations r
  6. join
  7. (select
  8. fbi.mid as mid,fbi.rid as rid,fbi.way as way from
  9. (select
  10. distinct r.member_id as mid, min(r.id) as rid, r.way as way
  11. from reservations r join members m on m.id = r.member_id
  12. where r.state = 'completed' and m.imaginary = 'normal' and m.email not like '%socar.my%' group by r.member_id) fbi
  13. where fbi.way in ('oneway','onewayReturn') ) fbo on fbo.rid = r.id
  14. where r.start_zone_id in ('244','245') or r.end_zone_id in ('244','245') )FB
  15. where date(FB.date + interval '8' hour) >= '2019-05-01'
Advertisement
Add Comment
Please, Sign In to add comment