SQL Practice Test

โ–ถ

Cracking SQL Interview Questions: A Hands-On Prep Guide

You opened this guide because a SQL interview is on the calendar โ€” or because your last one ended with a recruiter saying, "We'll be in touch." Either way, you want a clearer plan than "learn joins and hope for the best." That's fair. SQL interviews look simple on the surface (write a query, get a result), but they actually probe three things at once: your grasp of relational thinking, your speed on the keyboard, and your ability to explain trade-offs out loud while a stranger watches the cursor blink.

Most candidates over-prepare on syntax and under-prepare on the conversation around it. They can recite the difference between INNER JOIN and LEFT JOIN, but freeze when asked, "Why would you pick one over the other for this report?" That gap is where offers are lost. We're going to close it.

This article walks through what real SQL interviews look like in 2026, which question categories show up most, how PL/SQL changes the rules at Oracle-heavy shops, and the prep plan that actually moves the needle. You'll also get a checklist, a pros-and-cons look at popular practice platforms, and answers to the questions every candidate eventually asks. No fluff โ€” just the stuff that helps you walk in calmer and walk out with a better story.

Quick context before we dive in. The SQL hiring bar moved in the past two years. Three years ago, knowing how to write a clean JOIN with a couple of aggregates was enough for most analyst roles. Today, even entry-level data analyst postings ask about window functions and basic optimization. Engineering roles assume window functions are table stakes and probe execution plans. Why? The tools got better, but more importantly, the data got bigger โ€” and "works on my laptop" doesn't fly when production tables hit a billion rows.

So if the bar feels higher than what you remember from school, you're not imagining it. That's also why this guide isn't a syntax tour. There are great syntax tours out there. What you need is a model of how interviewers think and a plan that mirrors that model. Read it once now, then come back the night before your round to skim the checklist and the FAQ.

SQL Interview by the Numbers

75%
of data analyst and engineer roles list SQL as a required skill in 2026 job posts
5
core question categories tested across nearly every SQL interview format you'll meet
45 min
typical length of a single live SQL coding round before the conversation widens
3x
approximate pass-rate boost reported by candidates who followed a structured two-week prep plan

What SQL Interviews Actually Test

Let's start with the honest picture. A typical SQL interview round is 45 to 60 minutes. The interviewer shares a schema โ€” maybe three tables, maybe seven โ€” and asks you to write a series of queries. Easy ones first, then progressively harder. The shape of the conversation tells you what they care about, and it isn't always what you'd guess.

Take the numbers above. They look small, but they hide a story. Most candidates who fail don't fail because they can't write a GROUP BY. They fail because they pick the wrong join, miss a NULL edge case, or write something correct but slow. Interviewers know this. They build their question banks around exactly those traps.

Here's what you're really being measured on:

That last one surprises people. A correct query delivered in awkward silence often loses to a slightly-off query delivered with clear reasoning. The interviewer is also auditioning you as a teammate.

There's a subtler test running in the background, too: how well you handle ambiguity. Interviewers will sometimes deliberately leave a requirement vague โ€” "show me the top customers" โ€” to see if you ask clarifying questions. Top by what? Lifetime spend, last-90-day spend, order count? Silently picking one and writing the query is fine. Picking one without flagging the choice is a small mark against you. Asking, "By revenue or by order count? I'll go with revenue unless you say otherwise," is a small mark in your favor. The query that follows could be identical. The signal is different.

The other quiet test is how you respond to a hint. Strong candidates take a hint, acknowledge it, and adjust. Weaker candidates either ignore it (and dig deeper into the wrong solution) or accept it without understanding why. Interviewers drop hints on purpose to see which kind of teammate you'd be. Practice receiving hints gracefully โ€” they're a gift, not a verdict.

Communication Over Cleverness

A senior data engineer once told me, "I'd rather hire someone who writes a slightly slow query and explains it well than someone who writes a perfect query and can't tell me why." That captures the bar. SQL interviews are 60 percent technical, 40 percent communication โ€” and the 40 percent is where most candidates leak points without realizing it.

The takeaway: practice talking through your queries out loud, even when you're alone. Narrate your reasoning. Say why you picked a LEFT JOIN over an INNER JOIN. Explain the trade-off when you choose a CTE over a subquery. The habit feels strange at first, then it becomes second nature, then it becomes the thing that separates you from the candidate who interviewed before you.

The Five Question Categories That Dominate

If you scrape every SQL interview blog, every StrataScratch problem set, every Glassdoor dump, the same five buckets appear over and over. Knowing them lets you allocate prep time honestly instead of grinding random LeetCode lists.

Don't treat these as silos. A single "medium" question often blends three of them โ€” say, a window function inside a subquery filtered by a join. The bucket labels are useful for studying, not for solving. Think of them as the chords on a guitar: real songs use combinations, but you still drill each chord by itself until it's automatic.

The cards below break each bucket down. Read them once now, then come back after a few practice rounds and notice which ones felt slipperier than the others. That's your weak spot, and that's where the next chunk of prep time should go.

Five Question Categories You Will Meet

๐Ÿ”ด Joins & Set Operations

Inner, left, right, full outer, self-joins, plus UNION and EXCEPT. Expect questions on duplicate handling and NULL behavior, and at least one problem that forces you to explain when a self-join beats a window function.

๐ŸŸ  Aggregations & GROUP BY

Sums, counts, conditional aggregates with CASE, and the classic HAVING-vs-WHERE gotcha. Often combined with joins to test whether you remember that filters before and after aggregation behave very differently.

๐ŸŸก Window Functions

ROW_NUMBER, RANK, DENSE_RANK, LAG/LEAD, running totals, and partitioned aggregates. The single biggest skill jump for medium-to-hard problems, and the area where most self-taught candidates are caught flat-footed.

๐ŸŸข Subqueries & CTEs

Correlated subqueries, EXISTS vs IN, and recursive CTEs for hierarchical data. Readability matters as much as correctness here โ€” interviewers reward queries they can scan without parsing every line by hand.

๐Ÿ”ต Indexes & Optimization

When an index helps, when it hurts, and how to read an execution plan well enough to explain your choices. Even junior roles get one optimization question; senior roles often get three or four in a row.

PL/SQL: The Oracle Wrinkle

If your target role mentions Oracle, Apex, EBS, or anything finance- or telco-flavored, expect PL/SQL questions on top of regular SQL. PL/SQL is Oracle's procedural extension โ€” it adds loops, conditionals, exception handling, and the ability to package code as stored objects. The interview pattern shifts accordingly.

You won't just write a SELECT. You'll be asked to wrap logic in a procedure, return a result set through a REF CURSOR, handle a NO_DATA_FOUND exception gracefully, or explain when a trigger is the wrong tool. The bar isn't "can you write valid syntax" โ€” it's "do you know when to reach for PL/SQL versus a plain query versus the application layer."

A common live-coding ask: write a procedure that takes a department ID, loops through its employees, and applies a raise based on tenure. Sounds simple. The traps are everywhere โ€” cursor leaks, implicit commits, exceptions you forget to re-raise, and the classic mistake of doing row-by-row work when a single UPDATE would have finished in milliseconds.

Oracle and PL/SQL interview questions also tend to dig into packages โ€” bundles of related procedures and functions with a public spec and a private body. If you've never used them, spend an evening reading the syntax. Interviewers ask about packages because they reveal whether you've worked on real Oracle codebases or just touched the language in a tutorial. Bonus points if you can talk about package state, initialization blocks, and why the package body might be recompiled without breaking dependent code.

Performance comes up often, too. Be ready to explain bulk binds (BULK COLLECT, FORALL), why context switches between SQL and PL/SQL hurt, and the difference between EXECUTE IMMEDIATE and a static cursor. Even if you never use those daily, interviewers want to see you know they exist and roughly when each fits.

The tabs below break down the four PL/SQL constructs that come up most. Skim them even if you've used Oracle for years โ€” interviewers love to ask about the edges.

PL/SQL Constructs to Drill Before Oracle Interviews

๐Ÿ“‹ Procedures

Stored procedures wrap a block of PL/SQL that can be called by name. They accept IN, OUT, and IN OUT parameters and run in the database, not the app server. Interview question to expect: "When would you put logic in a procedure versus the application?" A good answer touches on data-locality, transaction scope, and security boundaries.

Be ready to write a small procedure on the spot โ€” usually one that takes a parameter, does a SELECT INTO, handles a NO_DATA_FOUND exception, and exits cleanly. The trap candidates fall into is forgetting the exception block entirely or writing one that swallows errors silently. Always re-raise unless you have a very specific reason not to.

๐Ÿ“‹ Functions

Functions return a single value (or a table, via pipelined functions) and can be called from inside SQL statements. The trap: forgetting they run once per row, which can tank a query. Be ready to explain when a deterministic function is safe versus when it forces row-by-row processing.

Pipelined functions are an Oracle specialty interviewers love to probe โ€” they let a function stream rows as it generates them, perfect for ETL-style transformations. If the role description mentions reporting or analytics, expect a question on these.

๐Ÿ“‹ Triggers

Triggers fire automatically on insert, update, or delete. Powerful, but interviewers often ask when not to use them. Answer: when the logic belongs in the application, when it makes debugging opaque, or when it causes cascading triggers that nobody can trace.

Know the difference between BEFORE and AFTER triggers, ROW-level versus STATEMENT-level, and the dreaded mutating table error. The last one alone has tripped up many otherwise-strong candidates โ€” explain it before the interviewer asks and you score quiet bonus points.

๐Ÿ“‹ Cursors & Packages

Explicit cursors let you fetch rows one at a time. Useful for row-level processing, dangerous if you forget to close them. Expect questions on FOR loops versus OPEN/FETCH/CLOSE, and on bulk operations with BULK COLLECT and FORALL โ€” Oracle's answer to slow row-by-row work.

Packages bundle related procedures and functions behind a public spec. Interviewers ask about packages because they reveal real Oracle experience. Bonus: know the difference between package-level state (session-scoped) and global variables, and be ready to explain why packages help with code organization, security, and dependency management.

Online Assessments and Take-Homes

Before you ever talk to a human, many companies route you through an online assessment. HackerRank, CodeSignal, DataLemur, StrataScratch โ€” the platforms vary, but the format rarely does. You get a problem, a schema, a sandbox, and a clock. Pass enough cases under time and you advance. Fail, and you usually don't get feedback.

These tests have a personality of their own. They reward speed over elegance, they don't care if your query would scale, and they sometimes accept inefficient solutions that a human interviewer would push back on. That's a feature, not a bug โ€” the goal is filtering, not judgment.

The format you'll meet most often: four to six SQL questions, ramping in difficulty, with a hard 60- to 90-minute cap. The first one is almost always a warm-up โ€” a basic SELECT with a filter. Don't be lulled. Treat the easy one as a chance to read the schema carefully and prime your brain. The harder problems usually re-use those same tables.

One under-discussed thing about SQL assessment tests: the platforms differ in how strict they are about row order. Some compare result sets as sets (order doesn't matter), some compare them as ordered lists (order does matter). If you're stuck and your answer looks right, add an explicit ORDER BY on the obvious key and re-submit. That single move fixes a surprising number of false failures.

Try a Free SQL Practice Test

The Prep Plan That Actually Works

Most prep advice is "do 100 problems." That's not a plan, that's a treadmill. Here's a structure that respects how memory actually works and how interviews are actually scored. Adjust the days to fit your runway โ€” the order matters more than the calendar.

The temptation is to start with hard problems to prove to yourself you can do it. Resist. Start with the schema-reading drills below, then move up. Your goal in week one is fluency, not flash. Fluency is what lets you write a join without thinking, so your brain has bandwidth left over for the parts that are hard. Skip this stage and every later stage feels heavier than it should.

If you only have one week, compress the checklist by doing fewer reps per day, not by skipping stages. The schema-reading drill on Day 1, the joins drill on Day 2, the windows drill on Day 3 โ€” that progression is the whole point. Doing windows before joins is like trying to write paragraphs before sentences. It works for some people. Most people stall.

Two-Week SQL Interview Prep Checklist

Day 1-2: Re-read your target company's data team blog posts and note their stack so you can mirror their vocabulary in interviews
Day 3-4: Drill joins until you can sketch the Venn diagram in your sleep and explain edge cases with NULLs without thinking
Day 5-6: Work through twenty GROUP BY problems with HAVING clauses at mixed difficulty levels โ€” focus on conditional aggregates
Day 7: Window functions deep dive โ€” RANK, DENSE_RANK, ROW_NUMBER, LAG, LEAD, running totals, and partitioned percentiles
Day 8-9: Subqueries and CTEs, prioritising readable solutions over clever one-liners that judges or interviewers will misread
Day 10: If Oracle role, full PL/SQL day โ€” procedures, cursors, exception handling, BULK COLLECT, and package basics
Day 11: Three timed mock assessments back to back to simulate fatigue and practice resetting between problems
Day 12: Two live mock interviews with a friend or paid coach, narrating every query out loud and asking clarifying questions
Day 13: Review every mistake from the past twelve days and rebuild a one-page personal cheat sheet in your own handwriting
Day 14: Light review only, no new problems, sleep early, hydrate, walk into the interview calm and warm

Practice Platforms: Honest Trade-offs

Every platform has fans and detractors. The right pick depends on where you're weakest, not on which one had the best landing page. Below is a side-by-side that should help you commit to one or two instead of bouncing between five.

A note on free versus paid: most platforms gate their hardest problems behind a paywall. If you're targeting FAANG-tier roles, paying for a month is usually worth it. If you're targeting analyst roles at a mid-market company, the free tiers are plenty.

One more habit to copy from people who land offers: keep a personal solution log. Every time you solve a problem, copy your final query into a notes file with a one-line summary of the trick. After two weeks you'll have your own cheat sheet, written in your own voice, that you can review on the train to your interview. Generic cheat sheets you downloaded from a forum don't stick. The one you wrote yourself does.

Comparing the Top Practice Platforms

Pros

  • StrataScratch uses real interview questions sourced from FAANG companies and well-known unicorns
  • LeetCode SQL has the largest free question pool and an interface most candidates are already used to navigating
  • DataLemur focuses on data-science-flavored SQL problems with cleaner explanations and a friendlier learning curve
  • All three platforms give you a sandbox so you can experiment with queries without installing a local database

Cons

  • StrataScratch's hardest and most realistic problems sit behind a paywall that's worth the cost only for serious candidates
  • LeetCode SQL community solutions often skew clever-but-impractical, which can teach habits real interviewers will push back on
  • DataLemur's catalog is smaller than its competitors, so heavy daily practice will exhaust the unique problems within weeks
  • None of them replace the unique value of one honest mock interview with a human who can react to your reasoning in real time

Mistakes That Quietly Sink Candidates

After running hundreds of mock interviews, the same handful of mistakes show up. Not syntax errors โ€” those are easy to fix. The real killers are habits. Read these out loud. If any of them sound familiar, that's the next thing to drill.

Going silent for long stretches is the most common. The second is over-engineering โ€” writing a CTE-stacked masterpiece when a two-line query would have done the job. The third is forgetting to validate the result. "This returns 47 rows" is a much stronger move than handing over a query and waiting for the interviewer's nod.

One more: tunnel-visioning on the first idea. Strong candidates pause, sketch the join graph in their head (or on paper), and then write. Weak candidates start typing immediately and refactor three times. Interviewers notice the difference within sixty seconds.

There's also the trap of leaning too hard on memorized templates. If you've drilled the gaps-and-islands pattern, you'll see it in problems where it doesn't actually fit, and you'll force it. Templates are a starting point. Always re-read the question after you've sketched a plan and ask, "Does this problem really need that pattern, or did I just want to use it?" Honest answers save offers.

Finally, the soft mistake: apologizing too much. "Sorry, I'm a bit rusty, sorry, that's not quite right, sorry, can I redo that?" Once is fine. Three times in ten minutes makes the interviewer wince. You're allowed to make mistakes โ€” that's expected. What you're not allowed to do is keep flagging your own performance. Fix the query, move on, project calm.

Take the SQL Skills Quiz Now

Putting It Together: Your Interview Day

Walk in with a routine. Open the editor, take a breath, read the schema twice before reading the question. Restate the question back to confirm. Sketch the relationships if you're allowed. Then write โ€” slowly, narrating, testing against tiny sample inputs in your head as you go.

If you get stuck, talk through what you'd try next instead of going dark. "I'm thinking I'd need a window function here to rank by date, but I want to make sure I handle ties โ€” should I use RANK or DENSE_RANK?" That single sentence does more for your score than three perfect queries delivered in silence.

Watch your pacing. A 45-minute round often hides three problems. Spending 25 minutes on the first one and then panic-rushing the rest is the most common time-management failure. Glance at the clock every five minutes. If you're past the halfway point of the round and still on the first problem, ask the interviewer if you should move on โ€” they often appreciate the awareness more than a stubborn finish.

When the round ends, debrief honestly with yourself. What did you fumble? What surprised you? Write it down within an hour, while the memory is sharp. That note becomes the next week's drill list. The candidates who improve fastest aren't the ones who do the most problems โ€” they're the ones who close their own gaps fastest.

A small ritual that helps: after every interview (mock or real), write three lines. What I did well. What I'd do differently. What I want to drill next. Three lines, no more. Over a month, those notes become a personalized prep curriculum that no generic course can match. They also calm the post-interview adrenaline โ€” turning anxious replays into structured improvement.

You've got the map now. The questions waiting for you on interview day will feel less alien because you've already seen their shapes. Run the prep plan, pick one platform and stick with it, and remember that interviewers want you to succeed โ€” they just need you to make it easy for them. Good luck. You're more prepared than you think.

SQL Questions and Answers

How many SQL interview questions should I practice before an interview?

Quality beats quantity. Sixty well-understood problems where you can explain every line trump three hundred you rushed through. Aim for breadth across the five core categories first, then depth on whichever bucket gave you the most trouble in mocks.

Do I need to know PL/SQL for every SQL interview?

No. PL/SQL is Oracle-specific. If the job description mentions Oracle, EBS, Apex, or stored procedures, study it. If the stack is Postgres, MySQL, Snowflake, or BigQuery, your time is better spent on window functions and query optimization.

What's the difference between SQL interview questions and a SQL assessment test?

Interview questions happen with a human, allow for back-and-forth, and reward communication. Assessment tests are timed, automated, and score correctness against hidden cases. Prep overlaps but the strategies differ โ€” assessments reward speed, interviews reward clarity.

Are StrataScratch SQL questions harder than what I'll see in a real interview?

They tend to be slightly harder than mid-market interviews and roughly on par with FAANG. If you can comfortably solve StrataScratch medium problems within twenty minutes, you're prepared for most live SQL rounds you'll encounter.

How do I prep when I haven't written SQL in months?

Start with three days of pure syntax refresh โ€” basic SELECTs, joins, GROUP BY โ€” before touching interview problems. Trying to learn syntax and problem-solving simultaneously is the fastest way to feel stuck. Build the muscle memory first, then the strategy.

What advanced SQL queries for interviews should I memorize?

Don't memorize queries; memorize patterns. Running totals with window functions, gaps-and-islands, top-N-per-group, hierarchical traversal with recursive CTEs, and pivot-style aggregation with conditional CASE. Master those five patterns and most "advanced" questions reduce to a known shape.

Is a SQL cheat sheet for interviews worth bringing to a remote interview?

Build one for your own study, not for the interview itself. Glancing at a cheat sheet on camera reads as unprepared. The act of building the sheet teaches you the material; by the time interview day arrives, you shouldn't need it open.

How important are SQL commands interview questions like DDL versus DML?

Less important than they used to be. Most modern interviews focus on querying (SELECT and its friends) rather than schema definition. That said, expect at least one question on transactions, ACID properties, or the difference between TRUNCATE and DELETE โ€” interviewers love those for spotting senior versus junior thinking.
โ–ถ Start Quiz