Write and execute SQL queries for the following tasks. Make suitable assumptions where necessary.
(a) Create the Employees table with EmpID as the primary key and DeptID as a foreign key referencing the Departments table. The Salary should not be negative. (4 Marks)
(b) List the names and salaries of all employees working in the 'Technology' department, sorted in descending order of their salary.
(c) Find the name of each department and the number of employees working in it. Display only those departments that have more than 10 employees.
(d) Find the names of all employees whose salary is greater than the average salary of all employees in the company.
(e) List the names of all projects along with the name of the employee who is leading the project.
Assuming we have two existing tables: `Departments(DeptID, DeptName)` and `Projects(ProjectID, ProjectName, LeadEmpID)`, here are the SQL queries for the tasks: (a) Create the Employees table: ```sql CREATE TABLE Employees ( EmpID INT PRIMARY KEY, EmpName VARCHAR(50) NOT NULL, DeptID INT, Salary DECIMAL(10,2) CHECK (Salary >= 0), FOREIGN KEY (DeptID) __________ ________ _________ ________ ________ _________ _____ _______ ____ __________ ________ _____.
_________ ______ _________ __________ _________ ________ ____ ___ ___ _____ ___.
_________ __________ _____ _______ ___ __________ _________ ________ _______ _______ ___.
_________ ______ __________ _______ _____.
______ __________ ___ ___ ___ ____ _______ __________.
______ ____ ___ _________ _________ _____ ________ _________.
____ _________ __________ ___ __________.
__________ _____ ______ _________ ________ _____ ________ ________ __________ _________ ______ ____.
_____ ______ ____ _________ ______ ______ _______ _________ ____ _______ _________ __________.
____ ______ __________ ___ ______.
____ ___ _____ _________ ___ _______ __________ _________ ____ _________ _______.
__________ ____ ______ _________ ______ _________ _________ __________ _____ ___.
____ ________ ______ _____ __________ __________ __________.
____ ____ ________ _______ ______ ___ _________ ______ _______ ____ _________.
________ __________ _________ ______ __________ _________ _____.
______ _____ ___ __________ ________ ______ _________ _____ ________ ___ _______.
________ ________ ___.
Get Full Answer on WhatsApp