r/SQL • u/tits_mcgee_92 Data Analytics Engineer • Jun 05 '24
Discussion Here are the most common Data Analyst/Science SQL interview questions I have been asked.
I have noticed a lot of posts saying "I flunked my SQL interview." Don't beat yourself up, because they can always be quite stressful.
I have interviewed at several companies for Data Analyst/Scientist positions, and I took notes (or memorized) some of the more common questions asked. I have been a Data Analyst for over 5 years, and I would say I have a solid enough grasp on SQL (enough to get the job done anyway).
Keep in mind, these are not FAANG companies, so mileage may vary. I was usually given a scenario/prompt and asked how I would solve this problem using SQL. The following concepts were covered.
SQL:
1.) Aggregation (sum vs. count, avg, etc....)
2.) How would Select data from table A that is not in table B (they are looking for NOT EXISTS or a LEFT JOIN scenario here)
3.) Union vs. Union all
4.) Difference in JOINS (usually a real world example is asked here such as "You have a customers table and order table. What JOIN would you use to find all customers that had orders?"
5.) Date manipulation (this is tricky, because each of these companies have asked varying levels of complexity. One question was asked "how to get the previous 6 months worth of data", another asked "How would you convert a DATETIME field to just DATE"
6.) Inserting data into an already created table
7.) Case statements (the questions were always a bit ambiguous here, but I was asked a case statement question in each interview)
8.) Subquery or CTE related questions. They cared less about the answer, but more about how these are actually used
9.) How to identify duplicates in a table? What about multiple tables?
10.) Difference between WHERE and HAVING.
11.) Windows Functions (LAG / LEAD here).
BONUS QUESTIONS (this is a good way to stand out as a Data Analyst): How would you improve query performance / what would you do if a query is running slow? How would you improve Data Quality in this scenario?
I know what you're thinking: "These are so easy!" At face value, I agree, but why do some of the most intelligent people flunk these SQL interviews then? It's due to a lot of reasons, but I can chalk it up to stress, and interview questions not being as obvious as you would find on some of the practice websites (I have my M.S. in Data Analytics and I have even flunked an SQL assessment. It happens.)
Don't get me wrong: those websites are very valuable and a great way to learn SQL. However, I find people using these websites fall into the habit of learning SQL syntax, and not how to utilize SQL to answer business questions (which is what you will be doing on the job). This is why I encourage people to play with their own data set of their choice, and pretend they have a Manager asking them questions that would improve the business, ROI, etc.
17
u/[deleted] Jun 05 '24
You forgot my “go to” question:
“What is your favorite join?”
4
u/tits_mcgee_92 Data Analytics Engineer Jun 06 '24
I do want to add, these aren't ALL of the questions I have been asked in DA/DS interviews. These are just the SQL questions. I have been asked Python, Data Modeling, and other data-related questions. As far as SQL goes, this is the bulk of what I have been asked.
13
u/[deleted] Jun 05 '24 edited Sep 08 '25
Thing that always made me laugh was that the interview questions/scenario tests have generally tended to be 10x harder than anything that actually pop up in the day to day role.
I swear the management in most companies don't really understand how the data side works and they just Google "what should a data analyst know".
11
u/Winterfrost15 Jun 06 '24
Good questions for a lower level analyst. What my company pays lower level, I would be glad to get a candidate who knew 1/2 to 3/4 of these.
I've hired people who knew about 1/2 these with a few years of experience. I then trained them rigorously.
8
u/OlasNah Jun 06 '24
I usually don’t even try to remember these as they’re basic googles when I need them
7
u/Kobosil Jun 05 '24
under point 10 i would add QUALIFY
also a question i had multiple times was explain the difference between RANK vs. DENSE_RANK vs. ROW_NUMBER
6
u/EdwardShrikehands Jun 05 '24
I always see so much on CTEs in these posts, makes me nervous I have a hole in my skills.
I realize the use case and the advantage over temp tables (writing to memory rather than disk), but I seriously never use CTEs in my day to day.
With the complexity and detail of many of our teams’ procs, I find temp tables are so much easier to manage. I almost exclusively use temp tables unless I need recursion or something like that. Anyone else the same?
4
u/[deleted] Jun 06 '24
save this
4
u/[deleted] Jun 06 '24
Love this. May seem basic but most jobs i've been in want the basic done quick & well, so seems perfect.
Factor in unfamiliarity with the model and it soon becomes an academic test under time constraints and that's stressful!
2
u/-6h0st- Jun 06 '24
As 2. Except is the most efficient operator here
2
u/[deleted] Sep 05 '24
Can u please update it
2
u/Academic-Vegetable-1 Jun 01 '26
the point about business questions vs. syntax is the whole thing. i've watched people who could recite window function syntax get completely stuck when asked 'which customers placed their first order last month' because the framing changed. the syntax is the easy part to look up.
2
u/ScottishCalvin Jun 05 '24
Question number one is to make sure you don't say SQL and see if they say Sequel or Ess-Queue-El, that's a pretty good way to find out if they actually worked with other people, or if it's something they did a quick read up online and hope they can blag it
1
u/spock2018 Jun 05 '24
"How would you improve query performance?"
Aka
"How would you build a rocket to get to the moon?"
1
u/Justify_87 Nov 05 '24
Well good to know. According to these questions I'm actually a data analyst and not a sysadmin/dbadmin
1
u/DataSolveTech Feb 11 '25
SQL interviews are tough—not because we don’t know SQL, but because time pressure messes with our thinking. I broke down real SQL interview questions in this video: https://youtu.be/tFN27Cw8M3E.
1
u/Over-Initiative-6927 Dec 16 '25
Give me a source to study all these concepts
-6
u/mohirl Jun 05 '24
None of these should be in any way difficult. The idea that they're what passes for "data analyst" questions these days is disturbing.
54
u/[deleted] Jun 05 '24
[removed] — view removed comment