Unique Leads and Partners by Date and Car Make
The sales team is analyzing daily activity by car make. For each date (date_id) and make (make_name), count the number of distinct leads (unique_leads) and distinct partners (unique_partners).
These ClickHouse SQL exercises focus on the kinds of data used in analytics: user events, purchases, logs, timestamps, and arrays. Practice calculating metrics, grouping events into time intervals, and using ClickHouse-specific functions alongside window functions. Your SQL runs in a real ClickHouse database and is automatically checked using hidden data. Problems: 535, free: 153.
Problems in this set: 535, free: 153
Start with a free problemProblems found: 153
Reset filtersThe sales team is analyzing daily activity by car make. For each date (date_id) and make (make_name), count the number of distinct leads (unique_leads) and distinct partners (unique_partners).
Return the name and bonus of each employee whose bonus is less than 1000. Include employees who have no bonus, too.
The academic administration wants to know which classes have enrolled enough students to start classes. Find all classes with 5 or more students. Return the class column.
A casting agency is looking for established actor-director partnerships. Return the actor_id and director_id for each actor-director pair that has worked together at least 3 times.
At MTS, a product analyst compiles a weekly ranking of customers by spending over the past month for triggered marketing campaigns and upsell offers. Today is 2026-05-05.
Lenta.ru tracks daily activity on its video platform: how many views videos receive in total and how many unique users watch them each day.
Alfa-Bank is analyzing customer purchases at partner stores. The marketing team wants to understand the demographics of smartwatch buyers so it can offer them gadget insurance.
The platform's marketing team is preparing a special offer for customers from Belarus. Return all information about passengers whose email addresses end with .by.
The pharmacy is reviewing its price tags. Return the name and price columns for all medications costing more than 6 euros. Sort the result by price in descending order, from most to least expensive.
Skypro's curriculum team wants to show only courses with enough reviews for a reliable rating on the landing page. Include only published courses (is_published = TRUE).
The cardiology head nurse is requesting patient-rounding forms for ward CARD-B. Count how many patients are currently in this ward.
The hospital registration desk needs a quick count of patients with the same first name. Count the female patients named Mary in the Patient table.
arrayJoin expands array elements into separate rows. One original event can therefore become several rows, changing subsequent counts and sums. If you need to count original events rather than array elements, check how the transformation affects the data, including events with empty arrays.
ClickHouse's uniq function returns an approximate number of distinct values. That may be appropriate for analytics, but it is not interchangeable with an exact count when precision matters. Check the problem's requirements before selecting a distinct-counting function.
argMax returns a value associated with the maximum of another expression. If several rows share that maximum, the selected value may not be deterministic. Consider whether tied timestamps or amounts are possible and whether the problem needs an additional way to choose between them.
Functions such as toStartOfHour group timestamps by interval boundaries. If the expected reporting timezone differs from the timestamp interpretation, events can land in the wrong hour or day. Inspect records near interval boundaries, especially around midnight, to catch these mistakes.
Yes. Every query executes in a real ClickHouse database, and its result is automatically checked against expected output using hidden data. The exercises cover event aggregation, arrays, time-based analysis, and window functions, so you can practice both syntax and analytical reasoning.
Yes. Free problems in this collection: 153. Once signed in, you can solve up to 3 new problems per day on the free plan. Premium problems are visible but require a subscription. Hints and an AI mentor are available in the problems.
arrayJoin expands the elements of an array into separate rows. This is useful when an event contains a list of products or other values that must be analyzed individually. Because it changes row counts, decide whether your later calculations should count original events or expanded elements.
Use countIf when you need to count rows that meet a condition, and sumIf when you need to sum values only for matching rows. Both are useful for event analytics, such as calculating views and purchases separately within the same grouping. Check which records qualify for each metric.
MergeTree is a family of ClickHouse table engines that matters when studying data storage and query performance. You do not need to understand every storage detail before practicing basic analytical queries. Start with selections and aggregates, then explore table engines as the problems become more advanced.