r/SQL • 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.

344 Upvotes

87 comments sorted by

View all comments

Show parent comments

4

u/kater543 Jun 05 '24

Different skill set. Data analyst/scientists are not data engineers or devs. SQL is a supplementary non mandatory skill for data analyst/scientists. Especially if your company has a robust data engineering core, data analysts and scientists can basically just stay in excel/R forever. While I am not saying SQL is not useful, it is not a core skill to those jobs vs a data engineer or database admin.

Edit: should say AS core of a skill. You can provide a ton of business value with just excel spreadsheets and no SQL skills.

1

u/DuxFemina22 Jun 09 '24

Hard disagree. SQL is a fundamental skill for both DA/DS. A lot of times we need to create our own custom data sets for analysis/models and/or it makes more sense to feature engineer directly at this level. Also understanding where the data is coming from and how it’s being pulled through the different sql models is pretty important.

2

u/kater543 Jun 09 '24

Nah. SQL is not a required core skill. You can also just use excel or Python. What I said is also especially true in companies where they do not have SQL servers and have no interest in setting one up, especially if their data is sparse. It’s equally true in companies that have strong data engineering teams that can build you any dataset you want so all you need is select * from table, which I think we can all agree isn’t SQL skills. You can also become a data analyst analyzing pure survey data that is easy to interpret, you’re just dashboarding it or pulling summary statistics or building hypothesis tests off of it. SQL is not a core or required skill for data analysts or data scientists. Very much just a nice to have, since it can qualify you for a wider range of jobs.

Also keep in mind that nowadays some data engineers don’t even need SQL… they just build their databases and pipelines through GUIs/python. All it requires is a fundamental understanding of database concepts. This is near anathema to me that Data engineers can have 0 idea of SQL but it’s how the world works now.

Technology has advanced and data is a far more mature industry, but even in the distant past data analysts existed without SQL.

0

u/mohirl Jun 05 '24

In which case none of the OP is valuable to people who are actually Data Analysts. The whole OP is SQL focused. So I've been approaching this from a dev-based DA role. 

Sure, actual data analysis could be Excel, SQL, Mongo, QuickBooks, whatever based. It's about actually being able to analyse data. Not parrot a Reddit post about basic SQL.

 My whole point is that the OP is terrible advice: it's either geared towards people who have zero DA experience trying to cheat their way into jobs they have no experience in; or companies trying to hire Data Analysts when they really need a DBA or don't know what they want.

But in terms of actual days analysts trying to find an actual data analysis role, it's literally the opposite of helpful