Question
Hi Expert, Please help to answer the SQL questions. You need to create the SQL syntax based on the case study given. This database has
Hi Expert,
Please help to answer the SQL questions. You need to create the SQL syntax based on the case study given.
This database has seven tables such as jobs, regions, countries, locations, dependents, employees, and departments. The following database diagram illustrates the HR database:
The HR sample database has seven tables:
1. The employees table stores the data of employees.
2. The jobs table stores the job data including job title and salary range.
3. The departments table stores department data.
4. The dependents table stores the employees dependents.
5. The locations table stores the location of the departments of the company.
6. The countries table stores the data of countries where the company is doing business.
7. The regions table stores the data of regions such as Asia, Europe, America, and the Middle East and Africa. The countries are grouped into regions.
The following picture shows the table names and their records.
Table | Rows |
employees | 40 |
dependents | 30 |
departments | 11 |
jobs | 11 |
locations | 7 |
countries | 25 |
regions | 4 |
Question :
1. Sort the salary data in the employees table's salary column from high to low. The values in this data must be unique.
2. Returns all rows in the employees table sorted by the first_name column. You must restrict to 5 data only.
3. Please merge the employees' and dependents' first and last names using the UNION operator. Be sure to sort the data by last name.
4. Identifies all employees with job ID 9 and salaries higher than 5,000.
5. Please answer this question using the employees table and the CASE expression. If the salary is less than 3000, the CASE expression returns Low. If the salary is between 3000 and 5000, it returns average. When the salary is greater than 5000, the CASE expression returns High.
6. Use the LIKE operator to find employees whose last names contain the word an.
7. Identifies employees with salaries above $14,000 and sorts the result set based on the salary in descending order.
8. Find all employees whose salaries are equal to the average salary of their department.
9. Finds all employees whose salaries are greater than 5,000 and less than 7,000:
10. Get the employees who work in the department id 5 and with a salary not greater than 5000.
11. Calculates the sum of salary that the company pays for each department and selects only the departments with the sum of salary between 20000 and 30000.
12. Retrieves the employee who has the lowest salary in each department, then sorts these departments by the salary in ascending order.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started