daily pastebin goal
74%
SHARE
TWEET

Untitled

a guest Oct 22nd, 2018 68 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
  1. SELECT avg(n_hours/n_slots) FROM
  2. (
  3. SELECT courier_id, COUNT(*) n_hours, SUM(CASE WHEN COALESCE(test > INTERVAL '1 hour', TRUE) THEN 1 ELSE 0 END) n_slots FROM (
  4. SELECT slot_time, courier_id,
  5. (slot_time - (lag(slot_time,1) OVER (partition BY courier_id ORDER BY slot_time))) AS test
  6. FROM scheduled_slots
  7. ) a
  8. GROUP BY courier_id) a
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top