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

5 Most Asked SQL Interview Question

5 most asked SQL Interview Question

Uploaded by

shivanimalode31
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

5 Most Asked SQL Interview Question

5 most asked SQL Interview Question

Uploaded by

shivanimalode31
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

5 most asked SQL Interview Questions for Data Analyst jobs 🎯

1. Calculate the average order value for each product category.


1️⃣

SELECT product_category,
AVG(order_value) AS avg_order_value
FROM orders
GROUP BY product_category;

2️⃣. Find the top 3 customers who have spent the most money in the past year.

SELECT customer_id,
SUM(amount) AS total_spending
FROM transactions
WHERE transaction_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR)
GROUP BY customer_id
ORDER BY total_spending DESC
LIMIT 3;

3️⃣. Count the number of orders placed in the previous year and month.

SELECT COUNT(*) AS order_count


FROM orders WHERE EXTRACT(YEAR_MONTH FROM order_date) = EXTRACT(YEAR_MONTH FROM
CURDATE() - INTERVAL 1 MONTH);

4️⃣. Calculate the total sales revenue for the past quarter.

SELECT SUM(revenue) AS total_sales_revenue


FROM transactions
WHERE transaction_date >= DATE_SUB(CURDATE(), INTERVAL 3 MONTH)
AND transaction_date <= CURDATE();

5️⃣. Determine the number of orders that have been canceled in the past year.

SELECT COUNT(*) AS canceled_orders


FROM orders
WHERE order_status = ‘Canceled’
AND order_date >= DATE_SUB(CURRENT_DATE, INTERVAL 1 YEAR)
AND order_date ≤CURRENT_DATE

You might also like