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

3rd LAB Program

The document outlines a lab program focused on SQL queries using aggregate functions such as COUNT, AVG, MIN, MAX, and SUM, along with GROUP BY and ORDER BY clauses. It includes instructions for creating an Employee table, counting employee names, and finding maximum and minimum ages, as well as sorting and grouping salaries. Sample SQL commands are provided for each task to demonstrate the implementation.

Uploaded by

bnmanya03
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)
4 views2 pages

3rd LAB Program

The document outlines a lab program focused on SQL queries using aggregate functions such as COUNT, AVG, MIN, MAX, and SUM, along with GROUP BY and ORDER BY clauses. It includes instructions for creating an Employee table, counting employee names, and finding maximum and minimum ages, as well as sorting and grouping salaries. Sample SQL commands are provided for each task to demonstrate the implementation.

Uploaded by

bnmanya03
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

3rd LAB Program

Queries using aggregate functions (COUNT, AVG, MIN, MAX, SUM),Group by, Order
by.
Employee (E_id, E_name, Age, Salary)
1. Create Employee table containing all Records E_id, E_name, Age, Salary.
2. Count number of employee names from Employee table
3. Find the Maximum age from Employee table.
4. Find the Minimum age from Employee table.
5. Find salaries of employee in Ascending Order.
6. Find grouped salaries of employees.

1. ANS
Creating the Employee Table
mysql> CREATE DATABASE COMPANY03;
mysql> USE COMPANY03;
mysql> CREATE TABLE Employee (
-> E_id INT PRIMARY KEY,
-> E_name VARCHAR(255),
-> Age INT,
-> Salary DECIMAL(10, 2)
-> );
mysql> DESC Employee;
Populating the Employee Table with 12 Records
2. ANS
Count Number of Employee Names
mysql> SELECT COUNT(E_name) AS TotalEmployees
-> FROM Employee;

3. ANS
Find the Maximum Age
mysql> SELECT MAX(Age) AS MaxAge
-> FROM Employee;

4. ANS
Find the Minimum Age
mysql> SELECT MIN(Age) AS MinAge
-> FROM Employee;

5. ANS
Find Salaries of Employees in Ascending Order

mysql> SELECT E_name, Salary


-> FROM Employee
-> ORDER BY Salary ASC;

6. ANS
Find Grouped Salaries of Employees
mysql> SELECT Salary, COUNT(*) AS EmployeeCount
-> FROM Employee
-> GROUP BY Salary;

You might also like