Lab schema (HR schema) is listed as below (primary keys are underlined):

Regions(region_id, region_name);
Countries(country_id, country_name, region_id);
Locations(location_id, street_address, postal_code, city, state_province, country_id);
Departments(department_id, department_name, manager_id, location_id);
Jobs(job_id, job_title, min_salary, max_salary);
Employees(employee_id, first_name, last_name, email, phone_number, hire_date, job_id, salary, commission_pct, manager_id, department_id);
Job_History(employee_id, start_date, end_date, job_id, department_id);

Learning Objectives:

Write queries to answer following questions.

  1. Who is/are the president(s) of this company?
  2. Who, except the president(s), earns the highest salary in this company? And what's their job title?
  3. What's the average salary (actually earned by the employees in this company) for each job title?
  4. Which employee(s) worked the longest in this company? And what's their job title, and how much they are earning now?
  5. Where are all the departments located?
  6. Which departments are newly created and haven't hired any employees yet?
  7. Which employees switched job titles more than 3 times?
  8. What is the whole company's human resource budget?