ahmedrahil786

Accident Members - Rahil

Oct 21st, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. set @startDate = "2017-01-01 00:00:00";
  2.  
  3. select Distinct A.mid as mid, Count(A.rid) as resv from
  4.  
  5. (select
  6. distinct c.reservation_id as rid,
  7. m.id as mid
  8. from charges c
  9. left join members m on m.id = c.member_id
  10. left join reservations r on r.id = c.reservation_id
  11. where c.kind = 'accident'
  12. and date(c.created_at + interval '8' hour) >= @startdate
  13. group by 1) A
  14. group by 1
Advertisement
Add Comment
Please, Sign In to add comment