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

DBMS Lab Exercise 3

The document outlines a practical exercise aimed at performing data manipulation commands and aggregate functions using SQL on created tables. It details the creation of two tables, 'sales_master' and 'sales_order', and provides a series of queries to execute various operations such as counting, summing, and updating records. Additionally, it includes aggregate functions like AVG, COUNT, MAX, and others for data analysis.

Uploaded by

hnpatil2821969
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views3 pages

DBMS Lab Exercise 3

The document outlines a practical exercise aimed at performing data manipulation commands and aggregate functions using SQL on created tables. It details the creation of two tables, 'sales_master' and 'sales_order', and provides a series of queries to execute various operations such as counting, summing, and updating records. Additionally, it includes aggregate functions like AVG, COUNT, MAX, and others for data analysis.

Uploaded by

hnpatil2821969
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

PRACTICAL - 3

AIM: To perform various data manipulation commands & aggregate


functions on all created tables.
Theory:

What is Function:
SQL has many built-in functions for performing calculations on data.

SQL Aggregate Function.

SQL aggregate functions return a single value, calculated from values in a column.

Useful aggregate functions:

 AVG() - Returns the average value


 COUNT() - Returns the number of rows
 FIRST() - Returns the first value
 LAST() - Returns the last value
 MAX() - Returns the largest value
 MIN() - Returns the smallest value
 SUM() - Returns the sum
PROGRAM EXECUTION:

1. Create a following table: sales_master

Col_name Datatype Size Attribute


Salesman_no varchar 6 primary key
Sal_name varchar 20 Not null
City varchar 40 Not null
pincode int 6,2 not null, cannot be 0
Sal_amt float 6,2 not null, cannot be 0
target_to_get float 6,2 not null, cannot be 0

2. Create a following table: sales_order

Col_name Datatype Size Attribute


S_order_no varchar 6 primary key
S_rder_date date Not null
Salesman_no Int 40 Foreign Key
Order_status varchar 30 Status like in-process,
fulfilled, cancelled
Dely_type varchar 20 Part, full, default-pending
S_order_qunity int cannot be less than 2

From the above given tables perform the following queries:

(1) List total number of sales_order from sales_order table.


(2) List total sale amount from Mumbai City.
(3) Give maximum order quantity from Salesman number ‘ S101’
(4) Count total number of Salesman..
(5) Count total number of cities.
(6) Create table sales_person from sales_master table with all the columns.
(7) Display the name of Salesman whose name starts with ‘A’ and its 6 character long.

(8) Write a query to set corresponding fields as Null in the sales_order table, if we delete the
record from sales master table.
(9) Delete the detail of supplier whose salesman number is ‘S105’

(10) Update the table such as way the if we Delete the records of ‘S103’ from salesmaster table
then details of ‘S103’ should get deleted from all the tables
(11) Count the number of orders which are in-process.
(12) Display the number of orders fulfilled between in the month of January 2023.
(13) Display the order numbers who have ordered more than 10 quantities.
(14) Display the name of salesman who do not based in ’Vadodara’.
(15) Delete the records of whoes order has been cancelled in the year ‘2020’

You might also like