These are SQL questions of the kind Amazon actually asks — the patterns reported from Amazon's SQL screens and data/SDE interview rounds. My advice: treat this page as a mock test. Attempt every question on paper first, then reveal. If any answer surprises you, the lesson it comes from is linked right below — go read it, then come back.
Amazon SQL query questions
Using the e-commerce schema (customers, orders, order_items, products), write a query to list, for customer 'Aditi Verma' only, each product she has ordered together with the order id, quantity purchased, and the line total (quantity x unit_price).
Asked in


customers4 rows
| customer_id | customer_name | city |
|---|---|---|
| 1 | Aditi Verma | Mumbai |
| 2 | Rohan Gupta | Delhi |
| 3 | Sneha Iyer | Bangalore |
| 4 | Karan Mehta | Mumbai |
orders4 rows
| order_id | customer_id | order_date | total_amount |
|---|---|---|---|
| 101 | 1 | 2023-01-05 | 1200.00 |
| 102 | 1 | 2023-02-10 | 800.00 |
| 103 | 2 | 2023-01-20 | 500.00 |
| 104 | 3 | 2023-03-01 | 1200.00 |
order_items6 rows
| item_id | order_id | product_id | quantity | unit_price |
|---|---|---|---|---|
| 1 | 101 | 501 | 2 | 300.00 |
| 2 | 101 | 502 | 1 | 600.00 |
| 3 | 102 | 501 | 1 | 300.00 |
| 4 | 102 | 503 | 1 | 500.00 |
| 5 | 103 | 503 | 1 | 500.00 |
| 6 | 104 | 502 | 2 | 600.00 |
products4 rows
| product_id | product_name | category | price |
|---|---|---|---|
| 501 | Wireless Mouse | Electronics | 300.00 |
| 502 | Mechanical Keyboard | Electronics | 600.00 |
| 503 | Desk Lamp | Home | 500.00 |
| 504 | Notebook Set | Stationery | 150.00 |
Given customers(customer_id, name) and orders(order_id, customer_id, order_date, amount), write a query using NOT EXISTS to find customers who have never placed an order.
Asked in


customers4 rows
| customer_id | name |
|---|---|
| 1 | Nina |
| 2 | Omar |
| 3 | Priya |
| 4 | Quinn |
orders3 rows
| order_id | customer_id | order_date | amount |
|---|---|---|---|
| 101 | 1 | 2026-01-05 | 250.00 |
| 102 | 1 | 2026-02-10 | 100.00 |
| 103 | 3 | 2026-01-20 | 75.00 |
Given an employees table with emp_id, name, dept_id, and salary, write a query using DENSE_RANK() to find the employee(s) with the second-highest salary within each department.
Asked in



employees6 rows
| emp_id | name | dept_id | salary |
|---|---|---|---|
| 1 | Alice | 10 | 90000 |
| 2 | Bob | 10 | 90000 |
| 3 | Carol | 10 | 80000 |
| 4 | David | 20 | 75000 |
| 5 | Eve | 20 | 70000 |
| 6 | Frank | 20 | 70000 |
How to use this page: Amazon rarely asks a question you've never seen — they ask standard patterns with a twist. Master the pattern in the SQL course lessons, and the twist stops mattering.
Keep practising: SQL Basics, Joins, GROUP BY & HAVING and Subqueries cover what most Amazon SQL rounds test.

