Employee Database. Retrieving data.

For the Company database write SQL queries to do the following:
  1. Select all department names and the names of their heads
  2. Select all departments of the first level (no sub-departments) and their bosses
  3. Select all department names, the names of their heads, and the number of employee in the department
  4. Select all department names and the names of their heads for only those departments where there are more than 5 employees
  5. Select all department bosses and their salaries only if the bosses salary is bigger than the average salary for the department.
  6. Select all the bosses of second level departments
  7. Compute the total salary for all sub-departments of a given department (let's say System).
  8. Print names and time of employment for all workers of a given department.
  9. 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.
  10. Select all people from first level departments whose salary is greater than the average salary for the whole company.
  11. Select bosses names and salaries for those whose salary is less than average bosses salary.
  12. Select names of all employees and their departments who are currently longer employed than their bosses.