Skip to content
Timed challenge

SQL Round, Kestrel's Numbers

An interview-style SQL round on Kestrel's live database: five questions from finance and operations, one query each, graded by the rows it returns.
  • Intermediate
  • 20 min
  • Challenge
  • SQL
  • PostgreSQL
  • Kestrel
  • Interview

Overview

Neha and Harpreet each have questions, and the answers are in the kestrel database (stores, products, stock, customers, orders, order_items). This is the round an interviewer gives you: one query per question, against the clock.

Write each answer as one SELECT in its own file, ~/rounds/q1.sql, ~/rounds/q2.sql and so on. Try it with psql kestrel -f ~/rounds/q1.sql. It is graded by the rows it returns: exactly the columns asked for, in that order, sorted as asked. Column names do not matter. Money is integer paise, as everywhere at Kestrel: never divide it.

What done looks like

  • Aggregate with GROUP BY and filter on status
  • Find rows with no match (an anti-join)
  • Rank with ORDER BY and LIMIT, breaking ties deterministically
  • Pick one row per group

Before you start

  • Databases & SQL, or SELECT, JOIN, GROUP BY and ORDER BY
  • Timed challenge: failed checks return no hints

Learn the skills first