It's Your Turn!
The goal of this exercise is to write queries in a database to find the answers to specific questions. This database models a company in which people are employed in different departments.
The database you'll use contains the following six tables:
employees: company employees
titles: the job title under which the employee was hired
salaries: the salaries of the employees
departments: the company’s departments
dept_manager: the managers (heads) of the departments
dept_emp: the employees associated with a given department
These tables are summarized in this diagram:
For each question, provide the SQL query you used to obtain the result, along with a screen capture of the table that was returned by your query. If the result of a query contains many rows, a screen capture of only the first few rows is sufficient.
Display all of the rows of the employees table, showing only the employees’ first and last names.
Display all employees who were hired after August 1, 1999 (non-inclusive).
In this database, two tables are of the same schema. Combine them using a Union operator.
Display the identifier and different salaries of the employee who was born on this date: '1964-01-31', using a join.
Using the join operator, produce a table specifying the name(s) of the department(s) in which the employee associated with identifier 499902 has worked (the table must also contain the start and end dates of employment in each department, as well as the employee’s last name and first name).
Using aggregation, find out how many people have the last name "Gewali" (the last name is provided in the last_name column of the "employees" table).
The SQL queries
A screen capture of the table