ahmedrahil786

Number of Bookings Each Day

Mar 12th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. SELECT
  2. distinct r.id,
  3. sum(p.amount) as amount,
  4. date(r.occupy_start_at + interval '8' hour) as days,
  5. count(r.state) as bookings
  6. from payments p
  7. join
  8. reservations r
  9. on p.member_id = r.member_id
  10. where r.occupy_start_at + interval '8' hour >= '2019-2-1 00:00'
  11. and r.occupy_start_at + interval '8' hour <= '2019-2-28 00:00'
  12. and r.state = "completed"
  13.  
  14. group by 1
Advertisement
Add Comment
Please, Sign In to add comment