ClickHouse Functions
ClickHouse function reference for TypeScript developers
A curated set of common ClickHouse functions for analytics, with SQL and hypequery examples for date bucketing, aggregation, string manipulation, conditionals, and numeric bucketing.
Functions covered
20
Clusters
Date · Aggregate · String · Conditional · Math
Each page includes
SQL + query-builder examples
Date Functions
Date and time functions for bucketing, truncating, and formatting timestamps — the foundation of every ClickHouse analytics query.
toStartOfDay()Truncate a DateTime to midnight — the foundation of daily analytics bucketing.
View reference →
toStartOfWeek()Round a DateTime to the start of the week — weekly cohort and trend analysis.
View reference →
toStartOfMonth()Truncate a DateTime to the first day of the month for MoM reporting.
View reference →
toStartOfQuarter()Round a DateTime to the first day of the quarter for QoQ reporting.
View reference →
toStartOfInterval()Bucket by any arbitrary interval — 5-minute, hourly, bi-weekly, or custom.
View reference →
now()Return the current server DateTime — the anchor for relative time filters.
View reference →
toDate()Convert a string or DateTime to a ClickHouse Date value.
View reference →
formatDateTime()Format a DateTime as a string using strftime-style patterns.
View reference →
Aggregate Functions
Aggregate functions for counting, summing, averaging, and estimating cardinality across millions of rows.
count()Count rows or non-NULL values — ClickHouse's fastest aggregate.
View reference →
uniq()Approximate distinct count — fast cardinality estimation for DAU and unique visitors.
View reference →
sum()Sum numeric values — revenue totals, event counts, and metric roll-ups.
View reference →
avg()Calculate the arithmetic mean — average order value, session duration, latency.
View reference →
quantile()Percentile estimates — p50, p95, p99 for latency and performance metrics.
View reference →
groupArray()Collect values into an array — session stitching, event sequences, and path analysis.
View reference →
String Functions
String manipulation functions for formatting display values, parsing, and building composite keys.
Conditional Functions
Conditional expressions for inline branching, NULL handling, and multi-way value selection.
Math Functions
Math functions for rounding, integer arithmetic, and numeric bucketing.
Get started
Use common ClickHouse functions in typed TypeScript queries
hypequery generates a TypeScript schema from your live ClickHouse database. These examples show how to combine ClickHouse functions with the query builder, while using raw SQL expressions when the function is not wrapped by a dedicated helper.