1. Row count
count() returns the number of rows in each group.
count() AS requestsTyporithm · easy
Step 1 of 8 · intro card
Querying
Aggregate per group with ClickHouse functions: count() and sum() for totals, uniq() for fast approximate distinct counts, and quantile(0.95)(col) for percentiles.
GROUP BY collapses many rows into one row per key, and aggregate functions summarize each group.
uniq() gives a fast approximate distinct count, while uniqExact() is precise but heavier on memory.
quantile(0.95)(col) returns an approximate percentile — ideal for latency p95 and p99 dashboards.
count(), sum(), avg() for basic aggregates.
uniq() approximate vs uniqExact() exact.
quantile(0.95)(col) for percentiles.
SELECT
host,
count() AS requests,
uniq(user_id) AS approx_users,
quantile(0.95)(latency) AS p95
FROM metrics
GROUP BY host;Connect each part of the code to the concept before you type.
count() returns the number of rows in each group.
count() AS requestsuniq() estimates distinct counts fast; uniqExact() is the exact, slower variant.
uniq(user_id) AS approx_usersquantile(0.95)(col) computes an approximate p95 over the group.
quantile(0.95)(latency) AS p95GROUP BY collapses rows into one row per host.
GROUP BY hostRead the concept map and follow the code breakdown.
Type the implementation, repair mistakes and work through every recall exercise.
Use the final check without hints; revisit weak concepts in short practice sessions.