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

18. Lec 18 SQL Practice

The document contains SQL queries for retrieving sales data from a database. It calculates total and average sales and quantities for each distinct product, filtering results to include only those products with total sales less than 700 and a total quantity of 21. The queries utilize aggregation functions and grouping by ProductID.

Uploaded by

koulibalyhamam
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)
3 views1 page

18. Lec 18 SQL Practice

The document contains SQL queries for retrieving sales data from a database. It calculates total and average sales and quantities for each distinct product, filtering results to include only those products with total sales less than 700 and a total quantity of 21. The queries utilize aggregation functions and grouping by ProductID.

Uploaded by

koulibalyhamam
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

select * from dbo.

Sales

--Total Sales, Avg Sales, Total Quantity, Avg Quantity for each distinct product
select
ProductID,
sum(TotalAmount) [Sum of Sales],
sum(Quantity) [Total Quantity],
avg(TotalAmount) [Avg Amount],
avg(Quantity) [Avg Quantity]
from dbo.Sales
group by
ProductID
having sum(TotalAmount)<700 and sum(Quantity) = 21

You might also like