SQL most asked interview questions
SQL most asked interview questions
In this article, we will deal with ‘almost’ all types of SQL questions asked in any Analytics interview. These questions are mostly asked from candidates in the experience range of 0 to 6 years.
SQL questions are asked mostly in the 1st and 2nd rounds of your interviews and good feedback in it will definitely help you sail through the screening round.
How to use this tutorial?
There will be 4 sections to this article:-
1. General introduction on the types of questions asked
2. A few solved examples which you should first try and then gauge through the answer
3. Link to a few youtube videos which are created only on the most asked concepts in SQL
4. A few unsolved questions which you should attempt after going through 1,2 and 3
5. Optional – There will be a few books listed on our website with SQL most asked interview questions. If you think you need to master the concepts even further, then please go through it
What is the expectation of the SQL interviewer?
In a SQL interview, there are three types of questions asked:-
1. Simple definition like, what is the primary key, what is 1NF, 2NF, BCNF, etc.
Thumb rule – Don’t worry a lot about these questions, if you give a reading of any website on ‘SQL most asked questions’ then you will get answers to these questions. These articles are flooded with subjective questions. Do give it a read. We, at The Data Monk concentrate only on tricky and advance interview questions and we would not like to go that road. Having said that, it’s definitely an added advantage if you answer these questions. So, just go through it. Some sample questions will be given below
Weightage in interview -> 10-15%
2. Write query type questions
You will be recited or given a group of tables and you are supposed to write a query to find a given output. A very simple example would be to
‘Write a query to extract the 2nd most ordered item from the hotel with the least revenue’
Well, these are simple questions, all you need to do is to play around ranking, group by, order by, etc.
Weightage in interview -> 40-50%
In these types of questions, you are expected to provide the correct answer either on a server or you are supposed to write the complete code on a shared document/notepad.
We will surely look into these questions in the below section
3. Solving a real project problem
Every interviewer has solved a handful of complicated problems using SQL. These projects or queries are written in a span of a month or so, the interviewer will very wisely pick up a snippet or subset of the problem and would like to have a discussion on the approach to solve the problem.
Here, you are not expected to come up with a solution, but you need to think aloud with your logic. Most probably there will be multiple levels of the problem and you need to solve it in a methodological way.
I am working for a multiplex and I need to create a logic to find out where to allot a seat to a group of people. The solution needs to be dynamic. Suppose, there are 4 people who came to buy the ticket, then how you code will provide options to that person.
I started an application and overnight it got 100000 clicks. Now each day the data is growing and we are processing all the data at once. How will you design the database infrastructure?
(These questions are mostly asked to 3+ years, experienced candidates)
4. Creating or designing a complete dashboard pipeline
SQL is not the only thing that is practiced in the analytics domain. Analysts are required to create complete pipeline that should help create a working dashboard/ or report.
There are multiple tools to create pipeline like Airflow, Oozie, etc.
SQL is the backbone of all these pipelines, you create codes that will refresh for every day. These SQL codes contain variable like date between ‘D-1’ and ‘D-2’ where D-1 and D-2 is for yesterday and day before yesterday, this way the code runs everyday and refreshes numbers for the last two days.
Now in the interview you might be asked to create a simple pipeline where there are 3 codes A,B,C and it should run in the same sequence.
Try to practice such questions (at least two)
5. Understanding how SQL works
You should know the importance of optimization, partition, table and view creation, etc.
You will get a few questions from the interviewer to check if you have worked on Big Data because you need to know the concepts of partition and optimization.
For example, if you want to read the data for last one week then you need to add clause like
year>= 2022 and month >= 2 (If you are in March’22)
Now these columns should be included in the partition while creating the table.
You must have observed that with one question, we can check if you know the importance of scanning only relevant data and to scan this data you need to have partition in your table and that you should also know how to create a table. Boom !! The interviewer knows how much you know about SQL .
Now, if you are confused about starting SQL as a beginner and to reach to an interview ready state then do read this blog on How to prepare for SQL in 15 days
The Data Monk Interview Books – Don’t Miss
Now we are also available on our website where you can directly download the PDF of the topic you are interested in. At Amazon, each book costs ~299, on our website we have put it at a 60-80% discount. There are ~4000 solved interview questions prepared for you.
10 e-book bundle with 1400 interview questions spread across SQL, Python, Statistics, Case Studies, and Machine Learning Algorithms – Ideal for 0-3 years experienced candidates
23 E-book with ~2000 interview questions spread across AWS, SQL, Python, 10+ ML algorithms, MS Excel, and Case Studies – Complete Package for someone between 0 to 8 years of experience (The above 10 e-book bundle has a completely different set of e-books)
12 E-books for 12 Machine Learning algorithms with 1000+ interview questions – For those candidates who want to include any Machine Learning Algorithm in their resume and to learn/revise the important concepts. These 12 e-books are a part of the 23 e-book package
Important Resources to crack interviews (Mostly Free)
There are a few things which might be very useful for your preparation
The Data Monk Youtube channel – Here you will get only those videos that are asked in interviews for Data Analysts, Data Scientists, Machine Learning Engineers, Business Intelligence Engineers, Analytics Manager, etc.
Go through the watchlist which makes you uncomfortable:-
All the list of 200 videos
Complete Python Playlist for Data Science
Company-wise Data Science Interview Questions – Must Watch
All important Machine Learning Algorithm with code in Python
Complete Python Numpy Playlist
Complete Python Pandas Playlist
SQL Complete Playlist
Case Study and Guesstimates Complete Playlist
Complete Playlist of Statistics