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

SQL Interview Questions Coding

Uploaded by

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

SQL Interview Questions Coding

Uploaded by

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

SQL Interview Questions

Tables:
Customers Table
customer_id first_name last_name age country
1 John Doe 31 USA
2 Robert Luna 22 USA
3 David Robinson 22 UK
4 John Reinhardt 25 UK
5 Betty Doe 28 UAE

Orders Table
order_id item amount customer_id
1 Keyboard 400 4
2 Mouse 300 4
3 Monitor 12000 3
4 Keyboard 400 1
5 Mousepad 250 2

Shippings Table
shipping_id status customer
1 Pending 2
2 Pending 4
3 Delivered 3
4 Pending 5
5 Delivered 1

Intermediate and Advanced SQL Questions


1. Retrieve customers who have placed orders but do not have any shipping records.
2. Find customers who have orders and at least one "Delivered" shipping status.
3. Calculate the total spending of each customer, showing only customers who spent
above the average total amount.
4. Identify customers who ordered all the items listed in the Orders table.
5. Retrieve the most frequently ordered item and the customer(s) who ordered it the
most.
6. Identify customers with pending shipping statuses but no orders placed.
7. List customers who ordered multiple items of the same type.
8. Find customers whose total order value is greater than the combined total of all
orders made by customers from the UAE.
9. Rank customers by their total spending and display the top 3 spenders.
10. Retrieve the customer(s) who placed the highest number of orders.
11. Find customers who have shippings in both "Pending" and "Delivered" statuses.
12. Identify items that have never been ordered.
13. For each country, find the customer with the highest total order value.
14. Retrieve all customers who ordered an item whose price exceeds the average order
amount.
15. Determine the cumulative total spending for each customer, ordered by their most
recent orders.
16. Identify customers who have the same first name but live in different countries.
17. List customers who placed orders but do not appear in the Shippings table.
18. Find the difference in total spending between the youngest and oldest customers.
19. Calculate the percentage of orders placed by each customer relative to the total
number of orders.
20. Find customers whose total number of orders is within 10% of the maximum
number of orders placed by a single customer.
21. Identify customers who never ordered an item priced below 500.
22. Display the customers who have placed all their orders in the same country they
reside in.
23. Find customers who have the most distinct items in their order history.
24. Retrieve the shipping status for each customer’s most expensive order.

-By Sakshi Yadav

You might also like