Employee Database. Retrieving data.
For the Company database write SQL queries to do the following:
- Select all department names and the names of their heads
- Select all departments of the first level (no sub-departments) and their bosses
- Select all department names, the names of their heads, and the number of employee in the department
- Select all department names and the names of their heads for only those departments where there are more
than 5 employees
- Select all department bosses and their salaries only if the bosses salary is bigger than the average salary
for the department.
- Select all the bosses of second level departments
- Compute the total salary for all sub-departments of a given department (let's say System).
- Print names and time of employment for all workers of a given department.
- For each department print the department name and average time of employment only if this time is greater than
the average time of employment for the whole company.
- Select all people from first level departments whose salary is greater than the average salary for the whole
company.
- Select bosses names and salaries for those whose salary is less than average bosses salary.
- Select names of all employees and their departments who are currently longer employed than their bosses.