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

DBMS LAB CT

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

DBMS LAB CT

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

DBMS LAB CT

Name:- Akshat Jain


Section:- CS 5A
Roll no:- 2200290120019
Q1. Write an SQL statement to create the
Employees table with the columns specified
above.
CREATE TABLE Employee (
EmployeeID INT PRIMARY KEY,
FirstName VARCHAR(50),
LastName VARCHAR(50),
Age INT,
Department VARCHAR(50),
Salary DECIMAL(10, 2),
JoiningDate DATE
);
select * from employee

1. Alter the Employees table to add a new


column named Email of type
VARCHAR(100).
ALTER TABLE Employee
ADD Email VARCHAR(100);
2. Write an SQL query to rename the Salary
column to MonthlySalary.
ALTER TABLE Employees
RENAME COLUMN Salary TO MonthlySalary;
3. Drop the Employees table from the
database.
DROP TABLE Employee;

4.Insert a new employee with the following


details: • EmployeeID: 101 • FirstName:
'Alice' • LastName: 'Johnson' • Age: 29 •
Department: 'Finance' • Salary: 70000 •
JoiningDate: '2021-06-15'
INSERT INTO Employee (EmployeeID,
FirstName, LastName, Age, Department,
MonthlySalary, JoiningDate)
VALUES (101, 'Alice', 'Johnson', 29, 'Finance',
70000, '2021-06-15');

6. 2.3 Delete the employee record from the


Employees table where the EmployeeID is
101.
UPDATE Employees
SET MonthlySalary = 75000
WHERE EmployeeID = 101;

7. Write an SQL query to find all employees


who are older than 30.
SELECT * FROM Employees
WHERE Age > 30;

8. Retrieve a list of employees who work in


either the 'HR' or 'IT' department.
SELECT * FROM Employees
WHERE Department IN ('HR', 'IT');

9. Write a query to display the full names


(FirstName and LastName combined) of all
employees along with their current salary and
a calculated yearly salary (assuming 12
months).
SELECT CONCAT(FirstName, ' ', LastName)
AS FullName,
MonthlySalary,
(MonthlySalary * 12) AS YearlySalary
FROM Employees;

10.Find the average salary of employees in


the 'Sales' department.
SELECT AVG(MonthlySalary) AS AvgSalary
FROM Employees
WHERE Department = 'Sales';

11.Calculate the total number of employees


in the company.
SELECT COUNT(*) AS TotalEmployees
FROM Employees;

You might also like