The Amazon interview process is notoriously challenging, featuring multiple SQL rounds for almost al Data Analyst, Data Science, Data Engineering, and Business Intelligence roles. And while the work-life balance at Amazon isnt to die for, and the Amazon perks lack severely compared to other FAANG companies because Bezos is a notorious cheapskate, heres the silver lining: the compensation IS good at Amazon.
Real good, once you realize how much of your salary comes in Amazon stock, which has appreciated greatly (and will continue to appreciate until Amazon is the only store in the universe).
Thats why its worth your time to practice these 6 real Amazon SQL interview questions so you can Ace the SQL interview and land your dream job at Amazon where youll crush local small business one data-driven insight at a time!
What’s the difference between and ?
Essentially is to SELECT what is to SELECT DISTINCT.
RANK() gives you the ranking within your ordered partition. Ties have the same rank, with the next ranking(s) skipped. So, if you have 4 items at rank 2, the next rank listed would be ranked 6.
DENSE_RANK() also ranks within your ordered partition, BUT the ranks are consecutive. This means no ranks are skipped if there are ranks with multiple items, and the rank order depends on your clause.
6 Real Amazon SQL Interview Questions
Given the reviews table, write a query to get the average stars for each product every month.
The output should include the month in numerical value, product id, and average star rating rounded to two decimal places. Sort the output based on month followed by the product id.
Before peaking at the solution, you can try this real Amazon SQL interview question online in our interactive SQL code editor:
As we can see, there is no month column in the table. First, we have to extract the month from the column.
There is a simple function to extract month from a date. Heres the syntax:
You can look at this page for more explanation on the function.
After extracting the month in numerical values, get the average of the star ratings and round them to two decimal places. It can be achieved using the functions and . Please refer  &  for some reading on the functions.
Amazon databases are HUGE. How do you optimize a slow SQL query?
Note: the interviewer will likely push you for more detail, or ask you about a real example about a time you had to make one of these optimizations yourself. While this question might be out-of-scope for Data Analysts and Data Scientists, Amazon expects people interviewing for Data Engineering and Business Intelligence roles to know how databases work internally, and best practices for database design. If you arent familiar with these concepts, check out my article on how to prep for database design interviews.
Amazon Orders SQL Technical Assessment
This question about Amazon orders comes from a real Amazon Data Analyst SQL assessment. It’s a multi-part SQL question, similar to how take-home SQL challenges are structured, and asks increasingly more complex questions about the amazon orders.
Your given an table:
Here’s some sample data from :
You are also given an table:
Here’s some sample data from :
We’ve left the answers to this Amazon take-home challenge to the reader, but you can find a similar multi-part SQL assessment from CVS Health on Pharmacy Analytics which comes with full solutions.