You are on page 1of 4

NAME: GANESH

SURESH SUPE

ROLL NO. 2020300068

CLASS: SE COMPUTER

BATCH: D
SUBJECT: DBMS EXP.7

EXPERIMENT NAME – having group by clause

Practice work

mysql> select COUNT(client_no) AS No_Of_Clients, City FROM client_master GROUP BY City;


+---------------+--------+
| No_Of_Clients | City |
+---------------+--------+
| 4 | Bombay |
| 1 | Madras |
| 1 | Delhi |
+---------------+--------+
3 rows in set (1.68 sec)
mysql> select product_no, COUNT(qty_ordered) AS QUantity FROM sales_order_details GROUP
BY product_no;
+------------+----------+
| product_no | QUantity |
+------------+----------+
| P00001 | 4|
| P03453 | 2|
| P06734 | 1|
| P07868 | 1|
| P07885 | 2|
| P07965 | 2|

| P07975 | 2|
+------------+----------+
7 rows in set (1.66 sec
mysql> select product_no, SUM(qty_ordered) AS QUantity FROM sales_order_details GROUP
BY product_no;
+------------+----------+
| product_no | QUantity |
+------------+----------+
| P00001 | 34 |
| P03453 | 6|
| P06734 | 1|
| P07868 | 3|
| P07885 | 5|
| P07965 | 3|
| P07975 | 6|
+------------+----------+
7 rows in set (0.00 sec)

mysql> select product_master.product_no, product_master.description,


SUM(sales_order_details.qty_ordered)
-> FROM product_master INNER JOIN sales_order_details ON
product_master.product_no=sales_order_details.product_no
-> GROUP BY product_master.product_no;
+------------+---------------+--------------------------------------+
| product_no | description | SUM(sales_order_details.qty_ordered) |
+------------+---------------+--------------------------------------+
| P00001 | 1.44 Floppies | 34 |
| P07885 | CD Drive | 5|
| P07965 | 540 HDD | 3|
| P03453 | Monitors | 6|
| P06734 | Mouse | 1|
| P07975 | 1.44 Drive | 6|
| P07868 | Keyboards | 3|
+------------+---------------+--------------------------------------+
7 rows in set (0.00 sec)
Query Print the description and total qty sold for each product.

Output

Query Find the value of each product sold.

Output
Query Calculate the average qty sold for each client that has a maximum order value
of 15000.00

Output

Query Find out the sum total of all the billed orders for the month of January.

Output

Conclution I understood the concept of group by clause which is used to group rows by
column name & having clause which is used to check conditions involving
aggregate functions. I also learnt implementation of group by clause &
having clause.

You might also like