TGViewer
Data Science Jobs Data Science Jobs @datasciencej · 8.31K subscribers
Post #735 836
5⃣ frequently Asked SQL Interview Questions with Answers in data analyst interviews

📍1. Write a SQL query to find the average purchase amount for each customer. Assume you have two tables: Customers (CustomerID, Name) and Orders (OrderID, CustomerID, Amount).

SELECT c.CustomerID, c. Name, AVG(o.Amount) AS AveragePurchase
FROM Customers c
JOIN Orders o ON c.CustomerID = o.CustomerID
GROUP BY c.CustomerID, c. Name;


📍2. Write a query to find the employee with the minimum salary in each department from a table Employees with columns EmployeeID, Name, DepartmentID, and Salary.

SELECT e1.DepartmentID, e1.EmployeeID, e1 .Name, e1.Salary
FROM Employees e1
WHERE Salary = (SELECT MIN(Salary) FROM Employees e2 WHERE e2.DepartmentID = e1.DepartmentID);

📍3. Write a SQL query to find all products that have never been sold. Assume you have a table Products (ProductID, ProductName) and a table Sales (SaleID, ProductID, Quantity).

SELECT p.ProductID, p.ProductName
FROM Products p
LEFT JOIN Sales s ON p.ProductID = s.ProductID
WHERE s.ProductID IS NULL;

📍4. Given a table Orders with columns OrderID, CustomerID, OrderDate, and a table OrderItems with columns OrderID, ItemID, Quantity, write a query to find the customer with the highest total order quantity.

SELECT o.CustomerID, SUM(oi.Quantity) AS TotalQuantity
FROM Orders o
JOIN OrderItems oi ON o.OrderID = oi.OrderID
GROUP BY o.CustomerID
ORDER BY TotalQuantity DESC
LIMIT 1

;

📍5. Write a SQL query to find the earliest order date for each customer from a table Orders (OrderID, CustomerID, OrderDate).


SELECT CustomerID, MIN(OrderDate) AS EarliestOrderDate
FROM Orders
GROUP BY CustomerID


Hope it helps :)
  • ❤ 2
More from @datasciencej
  1. Sep 23, 2026✅ Deep Learning Models You Should Know 🧠📚 1️⃣ Feedforward Neural Networks (FNN) – Basic…
  2. Aug 18, 2026Honeywell is hiring Data Scientist 🚀 Experience : 0-1 Year Location : Bangalore Apply lin…
  3. Aug 13, 2026📊 Data Science Roadmap 🚀 📂 Start Here ∟📂 What is Data Science & Why It Matters? ∟📂 Ro…
  4. Aug 7, 2026Lanmea is hiring Role: SWE and AI Internship Batch: 2026/27 passouts Link: https://www.lan…
  5. Aug 6, 2026Want to Build Career in Data Science 📊? Join This Free Masterclass 📅 Date: Aug 7, 2026 ⏰…
  6. Aug 4, 2026Two Scholarships Open Now — Airtel (UG Engineering) & IDFC FIRST Bank (MBA) Two separate s…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →