Queries Related With Employee Schema
Queries Related With Employee Schema
SELECT name
FROM employee;
Q2. Find the name, address of employees who works for department number
C001.
Q3. Find the EID, start date of the employees who works for project number 201
or project number 301.
Q4. Find the name, EID of employees whose salary is greater than 20,000.
Q5. Retrieve all information of employees whose salary is greater than 20,000.
SELECT *
FROM employee
WHERE salary>20000;
Q6. Show the resulting salaries if every employee is given a 10 present raise.
Q10. Retrieve all possible combinations of EID and DName is the database.
Q11.Find the name of the department that employee Rajendra Gupta works for.
SELECT dname
FROM employee e, department d
WHERE e.deptid=d.deptid AND name=’Rahul Gupta’;
SELECT name
FROM employee
WHERE address LIKE ‘%Ram%’;
Q13. Retrieve a list of employees and the projects they are working on, order the
result by project’s name, within each project, order by employee’s name.
Q15. For each department with more than 8 employees, retrieve the department
number and the corresponding number of employees.
Q16. Find the average salary of all employees in the Animation department.
SELECT name
FROM employee
WHERE address IS null;
Q20. Retrieve the identification number, name and address of employees who
work for department number C001, S123, R101.
Q21. Retrieve the identification number of employees who work in the same
project that employee ‘601’ works in.
SELECT eid
FROM join
WHERE pcode IN (SELECT pcode FROM join WHERE eid=’601’);
Q22. Retrieve the identification number and the name of employees who have the
highest salary in the company.
Q23. Retrieve the name of employees whose salary is greater than at least one
employee of the department number L345.
SELECT name
FROM employee
WHERE salary>ANY(SELECT salary FROM employee WHERE deptid=’L345’);
Q24. Retrieve the name of each employee who has a department with the same
name as the employee.
SELECT name
FROM employee e
WHERE EXISTS
(SELECT * FROM department d WHERE d.eid=e.eid AND name=d.dname);