Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Login

Register Now

It will take less than 1 minute to register for lifetime. Bonus Tip - We don't send OTP to your email id Make Sure to use your own email id for free books and giveaways

5 Most Important SQL questions before you appear for your Data Science Interview

SQL is the bread and butter of an analyst. You can’t survive in the Data Science industry with a grip on this ‘easy-looking’ query language. I have been interviewed for more than 30 companies in the past 3-4 years. SQL rounds are mostly a rapid fire round where you either keep on answering all the answers or start missing them after a threshold.

This is one of those rounds in which you can impress the interviewer. Recently, I have been taking interviews and I can assure you that most of the logics asked in the interviews are repeated, no upto some extent, but completely repeated 😛

Following is the point charter:-
5 correct – SQL God, You are going to nail 9/10 SQL interviews
4 correct – Really Good, clearing the SQL rounds should not be a problem
3 correct – Ummm..Dicey, you should be able to crack a few rounds
2 correct – You need at least 2-3 weeks before you start applying
1 correct – Padh lo Beta, sochna bhi nai apply krne ka
0 correct – Try an MBA/MS in Analytics/SBI PO/UPSC

Please comment your answer or send it directly to me over Linkedin

Q1. Suppose there is a Movie Theatre with 26 rows(A,B,C..Z) and in each row you have 6 seats. The structure of table is given below

DateRow_NoSeat_NoOccupiedName
04-Apr-20AA1YesKuchi Bhi
04-Apr-20AA2YesKuchi Bhi
04-Apr-20AA3No
04-Apr-20AA4No
04-Apr-20AA5No
04-Apr-20AA6No
04-Apr-20BB1YesKuchi Bhi
04-Apr-20BB2No
04-Apr-20BB3No
04-Apr-20BB4YesKuch Bhi
04-Apr-20BB5No
04-Apr-20BB6YesKuchi Bhi
Table Name – PVR

First, let me know all the starting seats where the number of consecutive vacant seats is 2 (B2 here)
Secondly, write a generalised approach to solve for any number of vacant seats. Basically, you need to create a table with two columns,
1. Seat_No
2. Number of consecutive vacant seats

Q2. There are multiple ways to get the 3rd highest salary, write down at least three. This question is important because the moment you tell the interviewer the first way, he/she will ask to solve the same in any other way

Hint –
1. Naive Approach
2. Inner Query
3. Ranking


Q3. I don’t remember any interview which doesn’t have this question

Table ATable B
11
11
11
1
1

There are two tables, column name in Table A is X and in Table B is Y

How many rows will the resultant have, if you do:-
a. inner join
b. left join
c. right join
d. outer join
e. cross join

Justify your answer

Q4. I own 5 restaurants in Bangalore, following is the table of business, get me the date on which each of these restaurant crossed a total revenue of Rs.10,000

RestaurantDateRevenue
Bangalore Mandrian01/04/205000
Bangalore Mandrian02/04/204000
Bangalore Mandrian03/04/203000
Bangalore Mandrian04/04/206000
Boondock Bistro01/04/207000
Boondock Bistro02/04/203000
Boondock Bistro03/04/205000
Oliver’s02/04/2011000
Oliver’s03/04/208000
Oliver’s04/04/209000
Whitefiled Social02/04/2010000
Punjabi By Nature03/04/208000

Q5. There is a table with employee and manager information, the schema is given below. Write a query to get the EmployeeName and ManagerName.

Hint – Consider the edge cases, i.e. your query should cater the Manager Name of the CEO as well

You can access – 300+ Data Science Interview Questions covering SQL,R,Python,Case Studies, Guesstimates, Statistics, and Machine Learning Questions in the embedded link.

Keep Learning 🙂

The Data Monk

About TheDataMonkNewbie

I am the Co-Founder of The Data Monk. I have a total of 4+ years of analytics experience with 3+ years at Mu Sigma and 1 year at OYO. I am an active trader and a logically sarcastic idiot :)

Follow Me

Comments ( 2 )

  1. I have made my attempt at these questions. I want to find the author’s approach to these queries, where can I find that?

    TIA

Leave a reply