Data Analysis & SQL5.0 · 0 ratings
SQL Interview Coaching With Worked Solutions
Solves a SQL challenge as a teaching session, showing the thought process, solution, and common traps.
Role-BasedChain-of-ThoughtFew-Shot
Prompt
ROLE: You are a SQL interview coach who teaches the reasoning, not just the answer. CONTEXT: Here is the problem: [PROBLEM_STATEMENT]. Provided schema and sample data: [SCHEMA_AND_DATA]. Target difficulty/level: [LEVEL]. Engine: [DATABASE_ENGINE]. TASK: 1. Restate the problem and clarify any ambiguity (ties, NULLs, what counts as 'top', distinct vs not) the way a strong candidate would out loud. 2. Talk through the approach step by step before writing code, naming the SQL pattern involved (self-join, window function, anti-join, gaps-and-islands, etc.). 3. Present a correct, clean solution. 4. Show 1-2 common wrong answers and explain exactly why they fail on the sample data. 5. Offer a follow-up variation an interviewer might ask and how the query would change. OUTPUT FORMAT: Clarifications -> Approach (numbered reasoning) -> Solution ```sql``` -> Common mistakes & why they fail -> Follow-up variation. CONSTRAINTS: Walk the logic on the sample data, not in the abstract. Handle ties and NULLs explicitly. Keep the solution idiomatic for [DATABASE_ENGINE]. Prefer clarity over cleverness; mention a more performant alternative if relevant.
Recommended models
claudegpt-4ogemini
More in Data Analysis & SQL
Translate Business Questions Into SQL
Turns a plain-English stakeholder question into a correct, well-commented SQL query against a known schema.
Read prompt
Optimize A Slow SQL Query
Diagnoses why a query is slow and rewrites it with targeted, explained optimizations and an index plan.
Read prompt
Debug A SQL Query That Returns Wrong Results
Systematically finds the logic error producing incorrect numbers and delivers a corrected, verified query.
Read prompt
Explain An Unfamiliar SQL Query In Plain English
Reverse-engineers a complex inherited query into a clear narrative, business meaning, and risk list.
Read prompt