The document contains a series of SQL queries related to employee and department data management. It includes operations such as counting employees by town, retrieving distinct manager names for salesmen, identifying employees without managers, counting employees in different towns, and filtering employees based on hire dates. Additionally, it includes update and delete operations for employees hired before a specific date.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
3 views1 page
SQL Lab
The document contains a series of SQL queries related to employee and department data management. It includes operations such as counting employees by town, retrieving distinct manager names for salesmen, identifying employees without managers, counting employees in different towns, and filtering employees based on hire dates. Additionally, it includes update and delete operations for employees hired before a specific date.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1
1) SELECT d.dlocation AS Town, COUNT(e.eno) AS Employee_Count, AVG(e.
esalary) AS Average_Salary FROM EMPLOYEE e JOIN DEPARTMENT d ON e.edno = d.dno GROUP BY d.dlocation;
2) SELECT DISTINCT m.ename AS Manager_Name
FROM EMPLOYEE e JOIN EMPLOYEE m ON e.emgr = m.eno WHERE e.ejob = 'Salesman';
3) SELECT e.ename AS Employee_Name
FROM EMPLOYEE e WHERE e.eno NOT IN (SELECT DISTINCT emgr FROM EMPLOYEE WHERE emgr IS NOT NULL);
4) SELECT COUNT(e.eno) AS Employees_In_Different_Towns
FROM EMPLOYEE e JOIN DEPARTMENT ed ON e.edno = ed.dno JOIN EMPLOYEE m ON e.emgr = m.eno JOIN DEPARTMENT md ON m.edno = md.dno WHERE ed.dlocation != md.dlocation;
5) SELECT eno, ename, ejob, ehiredate
FROM EMPLOYEE WHERE ehiredate < '2003-01-01';
UPDATE EMPLOYEE e1 JOIN (SELECT eno FROM EMPLOYEE WHERE ehiredate < '2003-01-01') e2 ON e1.emgr = e2.eno SET e1.emgr = NULL;