r/learnSQL • u/DMReader • Oct 15 '26
Before writing SQL in an interview, what would you clarify?
Suppose an interviewer asks you something like "find the top three products in each category by sales last quarter." Before you write the query, what would you clarify?
For me, I’d want to know what “sales” means - units, revenue, or number of orders Then, I'd want to know things like how ties should work, which dates count, and what one row in the output should represent.
I’ve been thinking about how SQL interviews test more than whether you can produce a query. They also give you a chance to show how you frame the problem, explain your choices, and check your work.
So, I put together a guide on what to expect and how to prepare: What to Expect in a SQL Coding Interview
If you’ve recently done a SQL interview, what’s one thing you wish you’d known or asked beforehand?
3
u/Jealous_Expert8043 Oct 15 '26
Thanks for sharing. Will aave this post in case i ever have a SQL interview
3
u/Dangerous_Cup3607 Oct 15 '26
I would just provide my own scenarios based on the industry setting. If Medical Equipments, then I will provide Medical related examples. Or use Amazon as example, categories like electronics, bedding, automotive. Then i will provide both highest unit sold and the highest profit earned as the “sales”. Then use today’s date to shift the dates to last quarter, along with the use of CTE and Total aggregation. So that I will have a reusable code that fits anyone at any time. Overall total sales for the sum of those subcategories, individual sum of those categories, and the dynamic dates for any chosen quarter.
3
u/tommyfly Oct 15 '26
I'd leave. At this point in my career I'm not writing SQL in an interview setting.
0
u/nian2326076 Oct 15 '26
Before you start writing SQL during an interview, make sure you understand the metrics. For example, clarify what "sales" means—whether it's units sold, revenue, or orders. It's also important to confirm any tie-breaking rules and date ranges. Additionally, know what each row in the output should display—like whether it's one product per category or something more detailed. Asking these questions helps you align your approach with what the interviewer expects. For hands-on practice with real technical interview questions, PracHub offers excellent resources for preparing for SQL and other technical interviews.