Ex No: 17 Working with Summary Operations
Aim: To demonstrate the various summary operations available in MYSQL.
Procedure
a) Table Creation - Create product table with details such as product code, product name, product category, brand and price.
b) Insert 15 records in product table.
c) Display product details.
d) Display minimum and maximum price in a category.
e) Display averag price of product in all category.
f) Display product with maximum price in each category.
g) Display number of product sold by each brand.
h)Display distinct product category available.
i) Display product order by price lowest to highest in a category.
Query
a) Product Table Creation
 CREATE TABLE PRODUCT(
PROD_CODE INT PRIMARY KEY,
PROD_NAME VARCHAR(30) NOT NULL,
PROD_CAT VARCHAR(20),
BRAND VARCHAR(20),
PRICE INT);
            
b) Insert 15 records in product table
INSERT INTO PRODUCT(PROD_CODE,PROD_NAME,PROD_CAT,BRAND,PRICE)
VALUES(101,'8GB Pendrive','Storage','Sony',1200);
c) Query to Display Product details.
SELECT * FROM PRODUCT;
d) Query to Display Minimum and Maximum price in a product category
SELECT PROD_CODE, PROD_NAME, MIN(PRICE)
FROM PRODUCT
WHERE PROD_CAT='Laptop';

SELECT PROD_CODE, PROD_NAME, MAX(PRICE)
FROM PRODUCT
WHERE PROD_CAT='Laptop';
            
e) Query to Display average price of product in all category
SELECT PROD_CAT, AVG(PRICE)
FROM PRODUCT
GROUP BY PROD_CAT;
            
f) Query to Display Product with maximum price in each product category
SELECT PROD_NAME, BRAND, PROD_CAT, MAX(PRICE)
FROM PRODUCT
GROUP BY PROD_CAT;
            
g) Query to Display number of product sold by each brand
SELECT BRAND, PROD_CAT, COUNT(PROD_CAT)
FROM PRODUCT
GROUP BY BRAND, PROD_CAT;
            
h) Query to Display distinct product category
SELECT DISTINCT PROD_CAT FROM PRODUCT;
            
i) Query to Display product details order by price lowest to highes in a category
SELECT * FROM PRODUCT
WHERE PROD_CAT='Audio/Video' 
ORDER BY PRICE ASC;
            
Result: Thus summary operations has been performed using MYSQL queries.