Download our SQL Interview Cheat Sheet, and use it as a reference for your next SQL interview. Click below to download the SQL cheat sheet PDF and start preparing like a pro!
[Download the SQL Interview Cheat Sheet]
In case you want to preview the SQL interview cheat sheet, here you go:
If you need a more in-depth refresher on the SQL commands covered in this SQL interview cheat sheet, try our free SQL Tutorial - it covers everything from basic SQL commands, all the way up to more advanced SQL window functions and joins.
The cheat sheet covered everything from simple concepts like how to query data in a table to more difficult topics like aggregate and window functions.
Fetch all columns in the Customer Table:
Fetch OrderID and OrderDate Columns from the Orders Table:
Find the discount percentage for all orders:
Round the discount percentage to 2 decimal places:
Sort customers by age in the default ASCending order:
Sort customers by age in DESCending order (high to low):
AS is used to rename columns:
AS is also used to rename tables:
Fetch customers who are over the age of 35:
Fetch customers who live in a city that starts with “New”:
Fetch customers who live in North America:
Fetch customers that are not minors and not in the USA:
Inner Join
Left Join
Full Join
Right Join
Cross Join
Self Join
GROUP BY groups together rows with the same value in specified columns, It computes summaries (aggregates) for each unique combination of values.
The RANK() function is used to assign ranks to rows based on values in the specified column.
The LAG() function is used to access data from a previous row in the same result set without needing a self-join.
Divides rows into multiple groups, called partitions, to which the window function is applied.
Specifies the order of rows in each partition to which the window function is applied.
This query finds orders with the same order cost as order_id 101.
This query finds orders in cities that have a cost of over 200.
This query calculates the total sales per customer and then filters customers with total sales above 500.
A SQL Interview cheat sheet is a good way to refresh your understanding before an interview, but the best way to truly get ready is to practice tons of real SQL interview questions. Tackle these FAANG SQL interview questions to get started:
You can also practice SQL interview questions by concept or topic:
And if you’re looking for an all-around resource for conquering the Data Science Interview read this Amazon #1 Best selling book: Ace the Data Science Interview.