SQL practice problems

22 problems · 0 solved

SQL is the language for asking questions of data stored in tables. Even in ML teams, a large share of daily work is pulling numbers from logs, usage tables and experiment records. These problems use realistic data from LLM products, such as API calls, eval results and agent events, so the practice feels close to real work. You will total the tokens each model used on successful calls, find users whose spend is over a budget with HAVING, count failed training runs per project while keeping projects with zero failures, pick the best scoring model for each eval task with ROW_NUMBER, compute day-over-day percent change in cost per team with LAG, and split agent events into sessions by idle gap. Start with the Easy problems on GROUP BY and HAVING. Then do the outer join and ROW_NUMBER problems, and finish with LAG and sessionization, which use window functions in more involved ways. Most data and ML interviews include at least one SQL round, and window functions are where many candidates struggle, so steady practice here pays off quickly in both interviews and day to day analysis.

Easy 7

Medium 8

Hard 7

Related topics

All practice problems