TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

A Cool SQL Problem (and Why It Is Also a Bullshit SQL Problem)

3 pointsby mjirvalmost 6 years ago

1 comment

chupa-chupsalmost 6 years ago
<p><pre><code> 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 &lt;= tt.pointInTime and mm.end_time &gt; tt.pointInTime) group by tt.pointInTime order by tt.pointInTime </code></pre> (no idea if this is totally correct, just hacked together in a few minutes (postgresql))