0% found this document useful (0 votes)
11 views1 page

SQL Questions

The document contains a series of SQL-related questions and tasks, including explanations of SQL clauses like WHERE and HAVING, the use of DISTINCT, and the function of ORDER BY. It also covers SQL queries for retrieving sales data, handling joins, and preparing datasets for Power BI. Additionally, it addresses advanced SQL concepts such as CTEs, running totals, and optimizing queries for reporting purposes.

Uploaded by

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

SQL Questions

The document contains a series of SQL-related questions and tasks, including explanations of SQL clauses like WHERE and HAVING, the use of DISTINCT, and the function of ORDER BY. It also covers SQL queries for retrieving sales data, handling joins, and preparing datasets for Power BI. Additionally, it addresses advanced SQL concepts such as CTEs, running totals, and optimizing queries for reporting purposes.

Uploaded by

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

 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.

You might also like