Assignment 3 - Shouvik (1159)
Assignment 3 - Shouvik (1159)
Submitted By
Name: Shouvik Dhali
ID: 0242220005101159
Semester: Fall 2024
2
Section: 63_G1
Department of C.S.E.
Daffodil International University.
Date of Submission : 28/11/2024
Create a Table With (Foreign key and Primary key)
department_name VARCHAR(100)
);
employee_name VARCHAR(100),
department_id INT,
hire_date DATE,
);
\
Insert Values in Table
(1, 'HR'),
(2, 'IT'),
(3, 'Finance'),
(4, 'Marketing');
FROM Employees
OutPut
SELECT employee_name,salary
FROM Employees
LIMIT 3
Output
Output
Output
Output
SELECT employee_name
FROM Employees
WHERE salary != (SELECT MAX(salary) FROM Employees AND salary != (SELECT MIN (salary ) FROM Employees)
Output
10. Employees Who Are Paid More Than the Average Across All Departments
SELECT employee_name
FROM Employees
WHERE salary > (SELECT AVG(salary) FROM Employees);
Output
11. Departments with Employees Earning More than the Maximum Salary in IT
SELECT DISTINCT department_id
FROM Employees
WHERE salary > (SELECT MAX(salary) FROM Employees WHERE department_id = 2);
Output
SELECT employee_name
FROM Employees
WHERE hire_date > (SELECT DATE_SUB(MAX(hire_date), INTERVAL 3 YEAR) FROM Employees)
AND department_id != 2;
Output
SELECT
FROM Employees
WHERE salary < (SELECT MAX(salary) FROM Employees WHERE department_id =
Employees.department_id);
For Set Operation
-- Insert sample data into departments table with updated manager names
INSERT INTO departments (department_id, name, location, manager_name)
VALUES
(1, 'Engineering', 'New York', 'Emma Johnson'),
(2, 'HR', 'San Francisco', 'James Taylor'),
(3, 'Maintenance', 'Chicago', 'Oliver Miller'),
(4, 'Finance', 'Houston', 'Isabella Martinez');
2.Get a list of all employees working in departments located in 'ctg' or employees
earning more than $5000.
Output
3.Find employees who earn more than $7000 and also belong to department 2.
Output
4.Get employees who do not belong to any department located in 'Chicago'.
Output
Output
LIKE OPERATOR
Output
Output