0% found this document useful (0 votes)
11 views2 pages

SQL Aggregate

The document outlines a database table structure for products, including fields like product_id, product_name, category, price, and quantity. It presents a series of aggregate function questions divided into four parts, focusing on total counts, averages, maximums, minimums, and sums of product data, as well as conditions using WHERE and GROUP BY clauses. The questions aim to analyze product data in various ways, such as by category and price thresholds.

Uploaded by

poonam.shah
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 views2 pages

SQL Aggregate

The document outlines a database table structure for products, including fields like product_id, product_name, category, price, and quantity. It presents a series of aggregate function questions divided into four parts, focusing on total counts, averages, maximums, minimums, and sums of product data, as well as conditions using WHERE and GROUP BY clauses. The questions aim to analyze product data in various ways, such as by category and price thresholds.

Uploaded by

poonam.shah
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

Table: PRODUCT

PRODUCT(

product_id INT,

product_name VARCHAR(30),

category VARCHAR(20),

price INT,

quantity INT

);

Sample Data

product_ product_na quanti


category price
id me ty

Electronic 5500
1 Laptop 5
s 0

Electronic
2 Mouse 800 30
s

3 Chair Furniture 3000 10

4 Table Furniture 7000 6

Electronic 1200
5 Printer 4
s 0

Part A: Basic Aggregate Function Questions

1. Find the total number of products.

2. Find the average price of all products.

3. Find the highest priced product.

4. Find the lowest price among all products.

5. Find the sum of prices of all products.


Part B: Aggregate Functions with WHERE

6. Find the average price of Electronics products.

7. Count the number of products with quantity greater than 5.

8. Find the maximum price of Furniture products.

9. Find the minimum price of Electronics products.

10. Find the total price of products whose price is greater than
5,000.

Part C: Aggregate Functions with GROUP BY

11. Find the average price category-wise.

12. Find the total number of products in each category.

13. Find the maximum price in each category.

14. Find the minimum quantity in each category.

15. Find the sum of quantities category-wise.

Part D: GROUP BY with HAVING

16. Display categories having more than 2 products.

17. Display categories where average price is greater than


10,000.

18. Find categories whose maximum price is above 50,000.

19. Display categories having total quantity greater than 15.

20. Find categories where minimum quantity is less than 5.

You might also like