SQL SORTING and FILTERING on HR Database: Display the employee Id, first name, job id, and department number for those employees whose department number equals 30, 40 or 90
SQL SORTING and FILTERING on HR Database: Exercise-21 with Solution
21. From the following table, write a SQL query to find those employees whose department numbers are included in 30 or 40 or 90. Return employee id, first name, job id, department id.
Sample table : employees
SELECT employee_id, first_name, job_id, department_id FROM employees WHERE department_id IN (30 , 40 , 90);
employee_id | first_name | job_id | department_id -------------+------------+----------+--------------- 100 | Steven | AD_PRES | 90 101 | Neena | AD_VP | 90 102 | Lex | AD_VP | 90 114 | Den | PU_MAN | 30 115 | Alexander | PU_CLERK | 30 116 | Shelli | PU_CLERK | 30 117 | Sigal | PU_CLERK | 30 118 | Guy | PU_CLERK | 30 119 | Karen | PU_CLERK | 30 203 | Susan | HR_REP | 40 (10 rows)
Relational Algebra Expression:
Relational Algebra Tree:
Contribute your code and comments through Disqus.
Previous: From the following table, write a SQL query to find those employees who are working in the departments, which are not included in the department number 50 or 30 or 80. Return employee_id, first_name, job_id, department_id.
Next: From the following table, write a SQL query to find those employees who worked more than two jobs in the past. Return employee id.
Test your Programming skills with w3resource's quiz.
What is the difficulty level of this exercise?
SQL: Tips of the Day
MySQL export schema without data
mysqldump -h yourhostnameorIP -u root -p --no-data dbname > schema.sql
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework