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;
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;