Data Science SQL Interview Question Walkthrough (real interview style) | SQL Sundays #7
Key Takeaways
This video demonstrates a data science SQL interview question walkthrough, specifically finding the minimum, average, and maximum rental price for each review qualification category on Airbnb, using SQL queries with case statements and common table expressions (CTEs).
Full Transcript
and we're back with another sequel sunday let's jump into it okay so this question that we have here today is from airbnb find the minimum average and maximum rental price for each review qualification category the review qualification category is a classification applied to each rental property based on the number of reviews the property has okay so it's defined below like this cool okay let's look at the table here so okay airbnb search details this is a big table uh lots of things going on let's see [Music] so we want to look at the review qualification so we're looking at the number of reviews the property has so we're basing these um classification on that so let's see if one of these columns gives us a hint about the number of views okay okay bathroom blah blah blah blah oh okay cool so number of views is literally here this is really nice i actually thought that it would be more complex since you know maybe it would be like each review and you had to aggregate it but it has a number of views here for us that's great so let us have a plan and see what we're gonna do so finally we want our expected output to look like so reviews qualification oops slice spelling area there reviews qualification um let's comment this out main price average price and max price max price cool all right so what assumptions do i have okay so first assumption is that all the values are going to be an integer so i'm going to assume that we don't have any null values here um yeah so i'm going to assume that it's gonna be positive integers for this what other things do i have i think that's about it cool all right we can go on to right what we're gonna do so first thing we're gonna do is do the classification and to do this we're going to use case 1 statements should be pretty straightforward and then after we do that i am going to um just do aggregation so group by the rental price oops not rental price um group by qualification category and then aggregate min average and maximum price cool all right let's do this query so from airbnb search details a case when what is it called again number of reviews number of reviews is equal to zero then no one number of reviews is oops nice between one and five then few when number of reviews between 6 and 15 then [Music] [Applause] number of reviews between 16 and 40 than many when number of reviews actually i can just do this else a lot because we're assuming since um it's not going to be null and it's going to be positive so this should catch everything else that's more than 40 reviews okay so end as what is it called again oh yeah reviews qualification cool um so now we can do like a sub query for this uh like nested but i always prefer to use ct's because i just think it's a lot clearer for the interviewer to read and also for you to not get confused oh oops one thing one thing one thing uh we also need a price right because we are aggregating by price cool all right so let's call this with um [Music] class with reviews as here and we can do from reviews now we're going to group by qualification category so let's write the select statement first select reviews qualification um what is it minimum so minimum of price as bin price as price as average price and max price x max price as uh max price cool and then we're gonna group by one let's see let's see looks good to me fingers crossed ran our code oh no what happened oh oh my god i forgot to write the select statement whoops okay rookie mistake okay this should work now yay okay good we got this right all right is there any other way that we can optimize things you could use a sub query like just nest it and not save it as a table so that would optimize actually no i don't would that even optimize things um that's a good point let's check that out so let's see like ct versus sub query performance okay so they're actually the same since both provide the same information to query optimizer use more than once could be easily identifying calculators out could then be stored okay so they're actually the same times performance so i don't think we can actually optimize it based upon that and i don't think that we can optimize it in any other way either okay so they did us a sub query here um yeah it's pretty much the same solution it's just the subquery i generally just prefer using cts as opposed to subqueries we're done with this episode and feel free to check out strata scratch i will link it below as well alright see you guys next time suddenly you're nowhere to be found i turn around and everything has changed looking for a way to work it out i'm trying to find some peace [Music] is [Music] again [Music] everything we wanted turned to gold the past we chose the future on our side [Music] and the writing on the [Music] can you hear me we'll meet again [Music] dark for the sunrise clouds for a blue sky space for the traveling star [Music] strong from the inside you're still my lifeline i feel you wherever you the oak are where i met you and the writing on the statue i still remember happy words [Music] follow me again you
Original Description
Hi friends! Welcome back to SQL Sundays! A weekly SQL data science interview questions and answers walkthrough.
This is another data science SQL interview question and answer done from beginning to end in a real interview style.
🔗Affiliates
========================
My SQL for data science interviews course (10 full interviews):
https://365datascience.com/learn-sql-for-data-science-interviews/
365 Data Science:
https://365datascience.pxf.io/WD0za3 (link for 57% discount for their complete data science training)
Check out StrataScratch for data science interview prep:
https://stratascratch.com/?via=tina
📲Socials
========================
instagram: https://www.instagram.com/hellotinah/
linkedin: https://www.linkedin.com/in/tinaw-h/
discord: https://discord.gg/5mMAtprshX
🤯Study with Tina
========================
Study with Tina channel:
https://www.youtube.com/channel/UCI8JpGrDmtggrryhml8kFGw
How to make a studying scoreboard:
https://www.youtube.com/watch?v=KAVw910mIrI
Scoreboard website:
scoreboardswithtina.com
livestreaming google calendar:
https://bit.ly/3wvPzHB
🎥Other videos you might be interested in
========================
SQL Sundays Playlist:
https://www.youtube.com/playlist?list=PLVD3APpfd1tuXrXBWAntLx4tNaONro5dA
How I learned SQL from Scratch in 11 Days to Pass my FANNG SQL Interview: https://www.youtube.com/watch?v=vaD3ZFFNwhM
How I consistently study with a full-time job:
https://www.youtube.com/watch?v=INymz5VwLmk
How I would learn to code (if I could start over):
https://www.youtube.com/watch?v=MHPGeQD8TvI&t=84s
🐈⬛🐈⬛About me
========================
Hi, my name is Tina and I'm a data scientist at a FAANG company. I was pre-med studying pharmacology at the University of Toronto until I finally accepted that I would make a terrible doctor. I didn't know what to do with myself so I worked for a year as a research assistant for a bioinformatics lab where I learned how to code and became interested in data science. I then di
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Tina Huang · Tina Huang · 22 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
▶
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
How to choose between software engineering and data science | 5 Key Considerations
Tina Huang
How I got Software Engineering and Data Science Internships | Computer Science Job Search Part 1
Tina Huang
How I Became a Data Scientist | Computer Science Job Search Part 2
Tina Huang
3rd Year Statistics, Data Science, Computer Science Resume | Reviewing Your Resumes Ep. 1
Tina Huang
How to learn SQL for data science interview (the minimize effort maximize outcome way)
Tina Huang
3rd Year CS Resume (and asian drink) Review | Reviewing Your Resumes Ep. 2
Tina Huang
Are you a student? If yes, this is the best data science project for you!
Tina Huang
The Ultimate Guide to Land a Data Science Internship | schedule and time management survival guide
Tina Huang
Upenn MCIT Program Details and Real Student Experiences - Dr. Arvind Bhusnurmath
Tina Huang
Real Data Science SQL Interview Questions and Answers # 1 | Data Science Interview Questions
Tina Huang
3 More Unique and Impactful Projects to get a Data Science Job
Tina Huang
Real Data Science SQL Interview Questions and Answers # 2 | Data Science Interview Questions
Tina Huang
THANK YOU FOR 1000! | Proper intro | Random facts about myself
Tina Huang
A day in the life of a data scientist (FAANG data scientist remote)
Tina Huang
SQL Data Science Interview Questions and Answers (interview style walk-through) | Question 3
Tina Huang
Biology to Data Science (data professor's tips on how to get a data science research position)
Tina Huang
SQL Data Science Interview Questions and Answers (interview style walk-through) | SQL Sundays #4
Tina Huang
Data Science SQL Interview Question Walkthrough | SQL Sundays #5
Tina Huang
Data Science Resume Round-Up With @KenJee_ds - Episode 2
Tina Huang
SQL Data Science Interview Question Walkthrough | SQL Sundays #6
Tina Huang
Data Science vs Software Engineering Interview | 3 Key Differences
Tina Huang
Data Science SQL Interview Question Walkthrough (real interview style) | SQL Sundays #7
Tina Huang
The data science resume that got me my FAANG (MANGA?) job (entry level data scientist)
Tina Huang
Data Science SQL Interview Question Walkthrough (real interview style) | SQL Sundays #8
Tina Huang
Interview with a quant trader
Tina Huang
How I chose my masters degree (as an international student)
Tina Huang
The software engineering resume that got me into FAANG and Goldman Sachs (internship)
Tina Huang
3 tips to avoid debt for a masters #SHORTS
Tina Huang
A hard work day (ft. new NLP project) | FAANG data science isn't chill | vlog 1
Tina Huang
The comments sections are WILD | YouTube sentiment analysis - Data science project for beginners
Tina Huang
Do you have what it takes to be a great data scientist?
Tina Huang
How to learn data science in 2022 (the minimize effort maximize outcome way)
Tina Huang
A productive day as a data scientist | day in the life of a data scientist vlog #2
Tina Huang
How to learn math for data science (the minimize effort maximize outcome way)
Tina Huang
Internship that made me rethink my career...(technology summer analyst at Goldman Sachs)
Tina Huang
How to get a data science job
Tina Huang
cake and big sister advice 🖤
Tina Huang
the most underrated data job in 2021
Tina Huang
My career changing computer science masters degree in 15 minutes (Upenn MCIT)
Tina Huang
Data science interview tips (product and technical interviews)
Tina Huang
Needed to learn javascript in 3 hours - would not recommend
Tina Huang
from management consultant to software engineer | Humans of MCIT
Tina Huang
Overview, Review and Study Tips - Google Data Analytics Professional Certificate
Tina Huang
Overview, Review and Study Tips - Google Data Analytics Professional Certificate (condensed version)
Tina Huang
Watch this video before applying to Georgia Tech OMSCS
Tina Huang
How to self study technical things
Tina Huang
What's the best certificate for data analysts? Google vs IBM Data Analyst Certificate
Tina Huang
FAANG Data scientist reviews: Datacamp, Dataquest, 365 Data Science
Tina Huang
How I would learn to code (if I could start over)
Tina Huang
The quant trader interview guide
Tina Huang
We code a trading bot live! @jacobamaral
Tina Huang
Why you should have a portfolio website
Tina Huang
60k cooking and Q&A (ft. Uncle Roger fried rice)
Tina Huang
How to self study using MOOCS (Udemy, Coursera, and other online courses) | self study online
Tina Huang
Data Science SQL Interview Question Walkthrough | SQL Sundays #9
Tina Huang
Watch me build my portfolio! | How to create a portfolio website
Tina Huang
How I stop myself from burning out
Tina Huang
How I take notes - Tips for efficient note taking that speeds up learning
Tina Huang
How I design effective study plans for ANY SUBJECT (and stick with them) | trading, coding etc.
Tina Huang
How I'm learning to trade (forex swing trading)
Tina Huang
More on: SQL Analytics
View skill →Related Reads
📰
📰
📰
📰
Why CitedEvidence Believes Great Researchers Read Less Than You Think
Medium · AI
How to Write a Literature Review That Actually Argues Something
Medium · Machine Learning
I Built a Personal Paper Engine to Stop Losing Research Papers
Dev.to · Ethan
First time ARR users - some questions [D]
Reddit r/MachineLearning
🎓
Tutor Explanation
DeepCamp AI