0% found this document useful (0 votes)
10 views

HR_SQL_Practice_Tasks

Uploaded by

Saida Rasul
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

HR_SQL_Practice_Tasks

Uploaded by

Saida Rasul
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

SQL Practice Tasks Based on HR Schema

**Single Row Functions**

1. Extract employees whose `first_name` starts and ends with the same letter.

2. Retrieve the length of `department_name` for each department, including the position of the first

vowel.

3. Format the `hire_date` of employees to display the month as a word and the year.

4. Replace all occurrences of 'e' in `job_title` with '@' and display it.

5. Calculate the square root of the salary of employees.

**WHERE Clause**

6. Retrieve employees hired after the year 2015 with a salary between 3000 and 8000.

7. Show departments whose `department_name` contains exactly three words.

8. Display employees whose `manager_id` is either null or less than 120.

9. List countries in the `countries` table where `country_name` contains the substring 'land.'

10. Retrieve employees who joined within the last 6 months from today.

**Joins**

11. List employees along with the names of their managers, sorted by `manager_id`.

12. Retrieve the departments and their locations for cities that end with the letter 'n.'

13. List employees who work in departments located in regions with `region_id` greater than 3.

14. Display the names of employees who work in cities where the country is part of region 2.

15. Retrieve job titles along with the number of employees holding each title.

**Aggregations**

16. Count the number of employees in each department whose salary exceeds the average salary.

17. Find the minimum and maximum salary for each job title.
18. Retrieve the total salary paid to employees in departments located in 'Europe.'

19. List departments along with the average length of their `department_name`.

20. Calculate the total bonus (salary * commission_pct) paid to employees grouped by department.

**Advanced Queries**

21. Display the first and last names of employees whose names form palindromes.

22. Identify departments with no employees and display their names and location IDs.

23. List the names of employees who have been with the company for more than 10 years.

24. Retrieve all employees who do not have a job title starting with 'S.'

25. List locations where the total number of employees exceeds 50.

You might also like