ClickHouse: Filtering and Window Functions

Here’s another of my learnings from playing with ClickHouse. This one is about the QUALIFY clause. It is a filter that is evaluated after applying window functions, but before any GROUP BY clause. I had been thinking of this clause mainly as syntactic sugar - you can write SELECT number , COUNT () OVER ( PARTITION BY number % 3 ) AS partition_count FROM numbers ( 10 ) QUALIFY partition_count = 4…