r/learnSQL • u/jakingo • 2d ago
What kind of SQL questions do companies usually ask in technical interviews?
I'm preparing for SQL interviews and curious about what companies actually focus on during technical rounds.
Do they mostly ask basic queries, JOINs, subqueries, window functions, or real-world problem-solving questions? Would love to hear what you experienced in your interviews.
39
Upvotes
13
u/Existing-Mirror7787 2d ago
Based on two interviews I've had
One was a question asking theoretically what would you do to clean this input data & how (easy single line queries)
The other was a real piece of code in their company, asked me what it did & left me with it for 15 mins.
Safe to say I had no idea so when they came back 15 mins later I was just honest with them lol and wished them a good day
8
u/Imaginary__Bar 2d ago
It depends on the job.
As an interviewing manager for analysts I'm more interested in the approach to a problem rather than remembering the exact syntax of a query so I might whiteboard a problem with the candidates for 30-45 minutes.
We'd definitely cover order-of-operations, string/date manipulation, joins, subqueries/ctes, views & materialisation and if you get stuck just explain it in plain language".
Hiring someone as a DBA or a data engineer is similar, but I'd expect a greater level of autopilot from them.
7
u/Entre2017 2d ago
One asked me to describe a time I used SQL query to solve a real business issue or something like that.
5
u/nicopassaglia 2d ago
It depends on the role, but the questions cluster into a handful of types, roughly in this order of how often they come up:
What they're really checking in most of these is the edge cases: what happens with ties, with NULLs, with a customer who appears twice. Saying "this breaks if two people share the top salary, so I'd use DISTINCT" out loud is worth more than writing the query fast.
If you want to practice that set: I built a free page with 12 of these to solve in the browser, each checked on a real database and with the trap explained. No sign-up. https://getsheetdrill.com/sql/interview-questions
Disclosure, it's my project. The questions are the well-known types, not taken from any company's list.
4
u/akornato 2d ago
Most companies skip pure syntax trivia and jump straight into practical business scenarios. You will almost always face joins across multiple tables, aggregation with GROUP BY and HAVING, and edge cases like NULL values or duplicate records. Window functions like ROW_NUMBER, DENSE_RANK, and LAG or LEAD show up constantly for data roles, especially for questions asking you to find the top three earners per department or calculate month over month growth. Interviewers care less about whether you memorized obscure functions and much more about whether you understand how joins affect row counts, how to structure queries using common table expressions, and how to translate a vague prompt into clean logic.
When you practice, focus on writing queries against realistic business schemas and narrating your thought process out loud before typing. Interviewers want to see how you break down a complex problem, how you verify your output, and how you handle edge cases instead of rushing to an answer. My team actually built an interviews.chat to help candidates land their target offers by taking the stress out of live technical rounds, and we see people succeed most when they treat the session like an open collaboration rather than a silent exam.
2
u/Financial_Forky 2d ago
When I conduct interviews for analysts on my team, I usually show candidates a piece of real code, and then have them walk me through what it does. Along the way, I'll ask follow-up questions, such as "what other ways could I have solved this?", "why did I do x instead of y?", "are there any problems to my approach?", "what if I had done z instead?"
Although only 35 lines long, the code includes a CTE, a JOIN, a window function, a CREATE TABLE (including distribution type), and adding a specific type of index.
I also ask a few conversation questions on SQL, particularly on working with large data sets and the unique challenges they pose. I don't expect anyone to be perfect - I'm more interested in how they think through the code, and probing the edges of their understanding of various SQL elements.
2
u/nian2326076 2d ago
In SQL interviews, companies often focus on basic queries and real-world problem-solving scenarios. You can expect questions about JOINs, subqueries, and window functions, but the emphasis varies by role. Practicing with realistic scenarios can help solidify your understanding. For technical interview prep, you can use PracHub to tackle specific SQL questions and improve your problem-solving skills. Additionally, LandOffer can help you discover relevant job opportunities in the field.
2
u/Optimesh 1d ago
Know you joins, CTEs, window functions, union vs union all and count vs count distinct, if else, coalesce and order of operations and you should be good
1
u/BigRossatron 2d ago
I have only been asked SQL questions twice that I remember in over 15 years and one of those was 'can you do joins?' the other time they wanted me to explain how I checked and cleansed some data as a follow up to another question.
I have been asked a few times pre-interview to submit some daily SQL queries that I often write from scratch.
1
u/_Royalty_ 2d ago
I would try to understand the business applications for using different things. Generally they won't ask if you know LEAD, LAG, PARTITION BY, etc. but will give you an approximate data structure and ask how you'd go about fulfilling some business request. I'd focus on the order of operations within a standard query first then you can learn about the technicality of each. Read the documentation for the flavor of SQL you anticipate using.
1
u/Discordbothost 2d ago
Window functions trip people up most - ROW_NUMBER/RANK with PARTITION BY, and knowing when a self-join beats a window function. Good practice: write the same top-N-per-group report three ways and compare.
1
u/Aggressive_Ad_5454 2d ago
Self-join, in addition to the other stuff mentioned.
1
u/glimmer_joy_spark 2d ago
the biggest trap is memorizing syntax instead of understanding execution logic. Interviewers are looking for how you handle edge cases like NULL values in LEFT JOINs or duplicate rows from a BAD GROUP BY, not just if you can write a query that works on perfect data.
1
u/tmk_g 2d ago
Companies usually focus on JOINs, aggregations, subqueries, CTEs, and window functions, along with real-world problems involving customer behavior, revenue, and business metrics. To prepare, practice on platforms like StrataScratch, LeetCode, and HackerRank to get comfortable with different SQL interview questions and difficulty levels.
1
u/king_of_the_ranch 1d ago
The only time I had a SQL question was “we have several reports that take too long to run; how would you fix that with SQL?”
1
u/datadriven_io 1d ago
That's one company. For all you know, the BI thing would have been a socially acceptable excuse for rejecting you for some other reason. And even if it weren't, you got some real-world practice with the DE technical interviews. As it happens, datadriven.io covers sql joins practice. Don't put all your eggs in one basket, it's not very fault-tolerant :P
1
u/HopeIllustrious5178 1d ago
2 years ago during my interview for a data engineering type role at a F100 I got asked these questions, I did not have to type anything:
I do not think my company's hiring process is indicative of the overall industry's process tbh. It was shockingly non-technical for such a technical role. Lot of behavioral questions and really deep dives on my past work experience/projects. Which I guess you could pretty easily snuff out how technical someone is by how detailed their responses are about their past projects. But I expected a hands-on assessment and didn't get one.
1
u/AddAcrobatic6275 3h ago
Most interviews focus on joins, subqueries window functions, and practical scenarios.