v.19.5New Features

Added ASOF JOIN Which Allows to Run Queries That Join to the Most Recent Value Known

Added ASOF JOIN which allows to run queries that join to the most recent value known. #4774 #4867 #4863 #4875 (Martijn Bakker, Artem Zuikov)
ASOF JOIN was added to ClickHouse, enabling queries that join tables on the most recent available value rather than exact matching keys.

Why it matters

The addition of ASOF JOIN addresses the need to join tables by the nearest preceding key value instead of exact equality. This is particularly useful in time series and event data where you want to associate records with the latest prior matching event, improving analysis over timelines or sequences.

How to use it

Users can apply the ASOF JOIN syntax in their queries as follows:

SELECT ...
FROM table1
ASOF JOIN table2
ON table1.key <= table2.key


This performs a join where for each row in table1 it finds the most recent row in table2 with a key less than or equal to table1.key. The feature can be used similarly to other JOIN types with appropriate conditions.