What is the difference between WHERE and HAVING? Provide examples.
Write a query to retrieve total sales by region from a Sales table.
What does DISTINCT do? Give an example using a Customer table.
What is the use of ORDER BY? How would you sort by SalesAmount in descending order?
Write a query to return the top 5 products by revenue.
Explain joins with examples. What’s the difference between INNER JOIN, LEFT JOIN, and FULL
OUTER JOIN?
Combine two tables: Customer (CustomerID, Name) and Orders (OrderID, CustomerID, Amount) to
show customer name and total amount spent.
Write a query to calculate month-wise sales trends.
6. What is a CTE (Common Table Expression)? How is it different from a subquery?
7. Find customers who haven’t placed any orders.
How do you prepare a dataset in SQL to be imported into Power BI for dashboarding?
You need to create a slicer in Power BI for Category. Write an SQL query to fetch a unique list of
categories.
Write a query to generate a date-wise revenue chart.
Power BI shows duplicate values in a slicer — how do you handle it in the SQL layer?
How would you pivot data using SQL for a matrix view in Power BI (e.g., Monthly sales by Region)?
Advanced SQL (Power BI Reporting Use-Cases)
16. Write a query to calculate the running total (cumulative sum) of sales for each customer.
17. Find the top 3 selling products per category using RANK() or DENSE_RANK().
18. What’s the best way to handle slowly changing dimensions (SCD) in SQL for
reporting in Power BI?
19. Explain how you can optimize a SQL query to improve performance in Power BI
dashboards.
20. Write a query to return customer name, total sales, and their rank based on total
spending.