🧠 Scenario-Based SQL Interview Questions #8
Unanswered
hirenpatel1903
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
🧠 Scenario-Based SQL Interview Questions
A curated collection of scenario-based SQL interview questions with clear, concise solutions.
This repository is designed for beginners to advanced developers preparing for technical interviews, coding tests, and quick SQL revision.
🎯 Who Is This For?
📌 Table of Contents
1️⃣ Find Duplicate Records (Amazon)
Problem: Find duplicate rows based on multiple columns in a table.
Solution:
2️⃣ Retrieve the Second Highest Salary (Microsoft)
Problem: Find the second highest salary from the Employee table.
Solution:
3️⃣ Employees Without a Department (Uber)
Problem: Find employees who are not assigned to any department.
Solution:
4️⃣ Total Revenue Per Product (PayPal)
Problem: Calculate total revenue generated for each product.
Solution:
5️⃣ Top 3 Highest-Paid Employees (Google)
Problem: Retrieve the top 3 highest paid employees.
Solution:
6️⃣ Customers Who Purchased but Never Returned (Walmart)
Problem: Find customers who made purchases but never returned any product.
Solution:
7️⃣ Count Orders Per Customer (Meta)
Problem: Count the number of orders placed by each customer.
Solution:
8️⃣ Employees Joined in 2023 (Amazon)
Problem: Retrieve employees who joined in the year 2023.
Solution:
9️⃣ Average Order Value Per Customer (Microsoft)
Problem: Calculate average order value for each customer.
Solution:
🔟 Latest Order Per Customer (Uber)
Problem: Find the latest order date for each customer.
Solution:
1️⃣1️⃣ Products Never Sold
Problem: Identify products that have never been sold.
Solution:
1️⃣2️⃣ Most Selling Product (Adobe/Walmart)
Problem: Find the product with the highest quantity sold.
Solution:
1️⃣3️⃣ Revenue & Orders Per Region (Meta)
Problem: Calculate total revenue and number of orders for each region.
Solution:
1️⃣4️⃣ Customers With More Than 5 Orders (Amazon)
Problem: Count customers who placed more than 5 orders.
Solution:
1️⃣5️⃣ Orders Above Average Order Value (PayPal)
Problem: Find customers with orders above the average order value.
Solution:
1️⃣6️⃣ Employees Hired on Weekends (Google)
Problem: Find employees hired on Saturdays or Sundays.
Solution:
1️⃣7️⃣ Salary Between 50K and 100K (Microsoft)
Problem: Retrieve employees with salary between 50,000 and 100,000.
Solution:
1️⃣8️⃣ Monthly Sales Revenue & Orders (Google)
Problem: Calculate monthly revenue and order count.
Solution:
1️⃣9️⃣ Rank Employees by Salary per Department (Amazon)
Problem: Rank employees by salary within each department.
Solution:
2️⃣0️⃣ Find Customers Who Placed Orders Every Month in 2023 (Meta)
Problem: Find customers who placed at least one order every month in 2023.
Solution:
2️⃣1️⃣ Find Moving Average of Sales Over the Last 3 Days (Microsoft)
Problem: Calculate 3-day moving average of sales.
Solution:
2️⃣2️⃣ Identify the First and Last Order Date for Each Customer (Uber)
Problem: Get the first and last order dates for each customer.
Solution:
2️⃣3️⃣ Show Product Sales Distribution (Percent of Total Revenue) (PayPal)
Problem: Calculate percentage revenue contribution of each product.
Solution:
2️⃣4️⃣ Retrieve Customers Who Made Consecutive Purchases (2 Days) (Walmart)
Problem: Find customers who made purchases on consecutive days.
Solution:
2️⃣5️⃣ Find Churned Customers (No Orders in the Last 6 Months) (Amazon)
Problem: Identify customers with no orders in the last 6 months.
Solution:
2️⃣6️⃣ Calculate Cumulative Revenue by Day (Adobe)
Problem: Calculate cumulative revenue day by day.
Solution:
2️⃣7️⃣ Identify Top-Performing Departments by Average Salary (Google)
Problem: Find departments with highest average salary.
Solution:
2️⃣8️⃣ Find Customers Who Ordered More Than the Average Number of Orders Per Customer (Meta)
Problem: Identify customers who placed more orders than the average customer.
Solution:
2️⃣9️⃣ Calculate Revenue Generated from New Customers (First-Time Orders) (Microsoft)
Problem: Calculate revenue from customers on their first order only.
Solution:
3️⃣0️⃣ Find the Percentage of Employees in Each Department (Uber)
Problem: Calculate employee percentage per department.
Solution:
3️⃣1️⃣ Retrieve the Maximum Salary Difference Within Each Department (PayPal)
Problem: Find the salary range in each department.
Solution:
3️⃣2️⃣ Find Products That Contribute to 80% of the Revenue (Pareto Principle) (Walmart)
Problem: Identify products that make up 80% of revenue.
Solution:
3️⃣3️⃣ Show Last Purchase for Each Customer Along with Order Amount (Google)
Problem: Get the last order with amount for each customer.
Solution:
3️⃣4️⃣ Calculate Average Time Between Two Purchases for Each Customer (Meta)
Problem: Calculate average days between purchases for each customer.
Solution:
3️⃣5️⃣ Calculate Year-Over-Year Growth in Revenue (Microsoft)
Problem: Calculate yearly revenue and growth from previous year.
Solution:
3️⃣6️⃣ Detect Customers Whose Purchase Amount Is Higher Than Their Historical 90th Percentile (Amazon)
Problem: Find orders where purchase amount is in the top 10% for the customer.
Solution:
3️⃣7️⃣ Retrieve the Longest Gap Between Orders for Each Customer (Meta)
Problem: Find the longest number of days between two orders for each customer.
Solution:
3️⃣8️⃣ Identify Customers with Revenue Below the 10th Percentile (Google)
Problem: Find customers with total revenue below the 10th percentile.
Solution:
🧠 Interview Tips
🌐 Follow & Subscribe
Stay connected and support us online:
📊 Live YouTube Statistics
👉 Subscribe here: https://www.youtube.com/@einzigartige_/
Beta Was this translation helpful? Give feedback.
All reactions