
A Cool SQL Problem (and Why It Is Also a Bullshit SQL Problem) - mjirv
https://ryxcommar.com/2019/06/24/a-cool-sql-problem-and-why-it-is-also-a-bullshit-sql-problem/
======
chupa-chups

      with allTimes as (
          with
          startTimes as (
              select distinct start_time 
              from meetings
          ),
          endTimes as (
              select distinct end_time
              from meetings
          )
          select start_time as pointInTime from startTimes
          union select end_time as pointInTime from endTimes
      )
      select tt.pointInTime, count(*) from meetings mm
      inner join allTimes tt on (
          mm.start_time <= tt.pointInTime
          and mm.end_time > tt.pointInTime)
      group by tt.pointInTime
      order by tt.pointInTime
    

(no idea if this is totally correct, just hacked together in a few minutes
(postgresql))

