Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Using Aggregate Combinators in ClickHouse.
For example, the standard SQL way to write filtered aggregates is:
SELECT avg(number) FILTER (WHERE number > 50) FROM numbers(100)
But it is only supported by SQLite, PostgreSQL, and ClickHouse. While ClickHouse also provides a shorthand:
SELECT avgIf(number, number > 50) FROM numbers(100)
SELECT avg(DISTINCT number) SELECT avgDistinct(number)
WITH Region = 'us' AS segment1, Browser = 'Chrome' AS segment2 SELECT uniqIf(UserID, segment1), uniqIf(UserID, segment2) WHERE segment1 OR segment2
For example, the standard SQL way to write filtered aggregates is:
See https://modern-sql.com/feature/filterBut it is only supported by SQLite, PostgreSQL, and ClickHouse. While ClickHouse also provides a shorthand:
The same for DISTINCT: Why filtered aggregates are important? - They allow to implement the "segment comparison" feature in web analytics services. Most of the existing web analytics services are using ClickHouse: CloudFlare Analytics, Microsoft Clarity, Plausible Analytics, PostHog, Splitbee...