You are on page 1of 6

Computer Science and Engineering

Course Title: Database Systems Lab


Course Code: CSE - 210
Experiment No: Job No - 05
Experiment Title: Implementation of
MySQL Aggregate Function.

Submitted by: Submitted to:


Name: Ujjal Kumar Roy BABE SULTANA
ID: 191002326 Lecturer
Section: DC Department of CSE
Green University of Bangladesh
Department of CSE
Green University of Bangladesh

Date of Submission: 09-12-2020

©Ujjal Kumar Roy Page. 1


Problem 1:

Solution:
SELECT SUM(price*Quantity) as total_price
FROM products;

©Ujjal Kumar Roy Page. 2


Problem 2:
Write a query to get the maximum price of a stationary product.
Solution:

SELECT product_type,MAX(price * Quantity) as max


imum_price
FROM products
WHERE product_type='Stationary';

©Ujjal Kumar Roy Page. 3


Problem 3:
Write a query to list the number of product_type available in the
product table.
Solution:
SELECT product_type, COUNT(product_type)
as product_type_available
FROM products
GROUP by product_type;

©Ujjal Kumar Roy Page. 4


Problem 4:
Write a query to get the number of products with the same product
type.
Solution:
SELECT product_type, COUNT(Quantity) as same_pro
duct_type FROM products GROUP by product_type
ORDER BY same_product_type DESC;

©Ujjal Kumar Roy Page. 5


Problem 5:
Write a query to get the difference between the highest and lowest
price of a stationary product.
Solution:
SELECT product_type, (MAX(price)-MIN(price))
as difference_between_the_highest_and_lowest_pri
ce
FROM products
WHERE product_type='Stationary';

©Ujjal Kumar Roy Page. 6

You might also like