Abhay 51048 Dbms Ass 04
Abhay 51048 Dbms Ass 04
Number function
Aggregate Function
Character Function
Conversion Function
Date Function
DESCRIBE Department;
-- Insert sample data into Department table
INSERT INTO Department
VALUES
(10, 'HR');
INSERT INTO Department
VALUES
(20, 'Finance');
INSERT INTO Department
VALUES
(30, 'IT');
4. Write a query which concatenates the employee number, his name and manager
6. Display details of all employees who were hired earliest and latest
SELECT *
FROM Employee
WHERE HireDate IN (SELECT MIN(HireDate) FROM Employee UNION SELECT MAX(HireDate) FROM
Employee);
7. Find out the department in which the maximum number of employees works
SELECT DepartmentID
FROM (
SELECT DepartmentID, RANK() OVER (ORDER BY COUNT(*) DESC) AS RankEmp
FROM Employee
GROUP BY DepartmentID
)
WHERE RankEmp = 1;
8.Display information about employees who have the maximum number of employees
reporting to him
SELECT *
FROM Employee
WHERE EmployeeID IN (
SELECT ManagerID
FROM (
SELECT ManagerID, RANK() OVER (ORDER BY COUNT(*) DESC) AS RankEmp
FROM Employee
GROUP BY ManagerID
)
WHERE RankEmp = 1
);
9. Find the day of the week, time of the day, month and centuryon which SMITH joined.
10. Find number of months the PRESIDENT has worked for the company. Round the