0% found this document useful (0 votes)
2 views

5. SQL_Noted

SQL is crucial for data scientists as it is widely used in large-scale database technologies and is compatible with big data platforms. To learn SQL effectively, practice is essential, and various online resources are available. During interviews, candidates should demonstrate logical problem-solving, code quality, and effective communication while being familiar with common SQL topics and query frameworks.

Uploaded by

lakshmisai1190
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

5. SQL_Noted

SQL is crucial for data scientists as it is widely used in large-scale database technologies and is compatible with big data platforms. To learn SQL effectively, practice is essential, and various online resources are available. During interviews, candidates should demonstrate logical problem-solving, code quality, and effective communication while being familiar with common SQL topics and query frameworks.

Uploaded by

lakshmisai1190
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

SQL_noted

Why SQL is important?


1. Most popular large scale database technologies

a. sql, no sql, graph, distributed, high level difference


2. You will for sure use it as a Data scientist for you job task
3. Compatible with big data platform such as Spark, Hive et al.

a. relationship with sql and big data

How to learn SQL?


Practice Makes Perfect !!!
resources:
https://www.w3resource.com/sql/tutorials.php
https://leetcode.com/problemset/all/?search=sql
https://www.hackerrank.com/domains/sql
https://sqlzoo.net/wiki/SQL_Tutorial
What the interviewer is looking for?:

1. make logical connection between data and answer.

2. how to solve the problem step by step

3. think aloud and try to communicate with the interviewer for clarification.

4. explain your thought process and tell why you do this way

5. code quality, i.e. readable, edge case consideration, optimized efficiency

6. speed to come up with the solution

Interviewer is not your enemy! They are your friends!.

Common Interview Topics:


1. Case When
2. with as
3. Self Join
4. Distinct vs Group By

a. Sum + Count

b. Max + Min

5. Left vs Outer join


6. Union
7. Date Time
8. Wildcard
9. Subqueries
10. CTE
11. Having and Where
12. Indexing
13. window function

SQL Cheat Sheet — SQL Reference Guide for Data Analysis – Dataquest

SQL query framework


1. Clarify question:

a. make sure to understand data structure and column meaning.

b. understand target solution output


2. Step by step plan. For example,

a. step 1: join table by player id

b. step 2: filter by date

c. step 3: count the player group by player_id


3. review the code to optimize

a. syntax error

b. efficiency
Interviewer is not your enemy.

SQL Interview examples


Always from easy to hard!

Example 1:

Write an SQL query that reports the first login date for each player.
1. clarify
login date, and event date are the same? Yes
do you care about same player with different device login? N0

—++++player_id+++++first_log_date++++
event_date is in DATE format

2. script
SELECT player_id, event_date
FROM Activity
Order By event_date

SELECT player_id, MIN(event_date) as first_login_date


FROM Activity
GROUP BY player_id;

Example 2: . Use the same Activity table, write a SQL query that
reports the device that is first logged in for each player.
Use the same Activity table, write a SQL query that reports the device that is first logged
in for each player.

Example 3:

Write an SQL query that reports the products that were only sold in spring 2019.
Example 4:
Write an SQL query that reports the most experienced employees in each project. In
case of a tie, report all employees with the maximum number of experience years.

Example 5:
You are implementing a page recommendation system for a social media website. Your
system will recommended a page to user_id if the page is liked by at least one friend of
user_id and is not liked by user_id.
Write an SQL query to find all the possible page recommendations for every user. Each
recommendation should appear as a row in the result table with these columns:

You might also like