What this prompt does
This prompt builds a SQL interview drill tailored to a level and a schema instead of throwing random queries at you. You set [question_count] and [difficulty], give it a [db_schema], and it generates business questions in plain English. For each one it shows the expected result format, gives you time to write your query, then reveals an optimal solution with explanation, alternative approaches, performance analysis, and an indexing recommendation. The structure mirrors how SQL is actually tested in interviews: starting from a vague business ask and ending at a fast, correct query you can defend.
The variables tune realism and coverage so the practice transfers. [topics] steers which SQL concepts appear, from JOINs and window functions to CTEs and date math, [sql_dialect] makes the syntax match your target database, and [company_type] grounds the scenarios in believable business contexts rather than abstract tables. Each question ends with a complexity-increasing follow-up that ratchets the difficulty, and after the full set the AI scores you, spots patterns in your mistakes, and recommends specific areas to practice next.
When to use it
- Preparing for data or backend interviews that include a dedicated SQL round
- Drilling window functions and CTEs, which trip up many otherwise-strong candidates
- Practicing query optimization and learning which index would make a slow query fast
- Targeting a specific dialect like PostgreSQL or MySQL before an interview
- Building realistic muscle memory against a schema close to your real product
- Getting an honest score and a focused list of weak areas to revisit afterward
Example output
You get a numbered set of questions, each with a plain-English business prompt, the expected columns and sample rows, and a deliberate pause for your attempt. After you answer, it reveals the optimal query with an explanation, alternative approaches and why the optimal one wins, an indexing recommendation, and a harder follow-up question. At the end you receive a performance score, a breakdown of the recurring mistakes in your queries, and recommended practice areas.
Pro tips
- Set
[db_schema]to something close to a schema you actually work with so the patterns transfer to your job - Match
[sql_dialect]to your target database; window-function and date syntax differ enough between them to matter - Start
[difficulty]lower than you think and let the built-in follow-ups ratchet it up naturally - Use
[topics]to force coverage of your weak areas rather than the queries you are already comfortable writing - Always write your query before revealing the answer; the entire value of the drill is in the attempt
- After scoring, ask it to regenerate a fresh
[question_count]set focused only on the topics you missed