0% found this document useful (0 votes)
3 views

lab_program3

The document outlines SQL queries for managing an Employee table in a COMPANY03 database, including creating the table and inserting employee records. It demonstrates how to use aggregate functions like COUNT, MAX, MIN, and ORDER BY to analyze employee data. Additionally, it shows how to group salaries of employees for further insights.

Uploaded by

gayathri
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)
3 views

lab_program3

The document outlines SQL queries for managing an Employee table in a COMPANY03 database, including creating the table and inserting employee records. It demonstrates how to use aggregate functions like COUNT, MAX, MIN, and ORDER BY to analyze employee data. Additionally, it shows how to group salaries of employees for further insights.

Uploaded by

gayathri
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
You are on page 1/ 2

3. Queries using aggregate functions(COUNT,AVG,MIN,MAX,SUM),Group by,Orderby.

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.

CREATE DATABASE COMPANY03;

USE COMPANY03;

CREATE TABLE Employee ( E_id INT PRIMARY KEY, E_name VARCHAR(255), Age INT, Salary DECIMAL(10, 2) );

INSERT INTO Employee VALUES (101, 'Samarth', 30, 50000.00);

INSERT INTO Employee VALUES (102, 'Ramesh ', 25, 45000.00);

INSERT INTO Employee VALUES (103, 'Seema ', 35, 62000.00);

INSERT INTO Employee VALUES (104, 'Dennis Anil', 28, 52000.00);

INSERT INTO Employee VALUES (105, 'Rehman’, 32, 58000.00);

INSERT INTO Employee VALUES (106, 'Pavan Gowda', 40, 70000.00);

INSERT INTO Employee VALUES (107, 'Shruthi', 27, 48000.00);

INSERT INTO Employee VALUES (108, 'Sandesh', 29, 52000.00);

INSERT INTO Employee VALUES (109, 'Vikram ', 33, 62000.00);

INSERT INTO Employee VALUES (110, 'Praveen ', 26, 46000.00);

INSERT INTO Employee VALUES (111, 'Sophia ', 31, 55000.00);

INSERT INTO Employee VALUES (112, 'Darshan', 34, 63000.00);


SELECT COUNT(E_name) AS Total_Employees FROM Employee;

SELECT MAX(Age) AS MaxAge FROM Employee;

SELECT MIN(Age) AS MinAge FROM Employee;

SELECT E_name, Salary

FROM Employee

ORDER BY Salary ASC;

SELECT Salary, COUNT(*) AS EmployeeCount

FROM Employee

GROUP BY Salary;

You might also like