w3resource
SQL exercises

SQL SORTING and FILTERING on HR Database: Display the the full name, and department number for those employees who works either in department 70 or 90

SQL SORTING and FILTERING on HR Database: Exercise-13 with Solution

13. Write a query in SQL to display the the full name (first and last name), and department number for those employees who works either in department 70 or 90.

Sample table : employees


Sample Solution:

SELECT first_name ||' '|| last_name AS Full_Name, department_id
  FROM employees
   WHERE department_id = 70 
     OR department_id = 90;

OR

SELECT first_name ||' '|| last_name AS Full_Name, department_id
 FROM employees
  WHERE department_id IN (70 , 90);

Sample Output:

   full_name   | department_id
---------------+---------------
 Steven King   |            90
 Neena Kochhar |            90
 Lex De Haan   |            90
 Hermann Baer  |            70
(4 rows)

Practice Online


HR database model

Query Visualization for Sample Solution:

Duration:

Query visualization of Display the the full name, and department number for those employees who works either in department 70 or 90 - Duration

Rows:

Query visualization of Display the the full name, and department number for those employees who works either in department 70 or 90 - Rows

Cost:

Query visualization of Display the the full name, and department number for those employees who works either in department 70 or 90 - Cost

Query Visualization for alternate Sample Solution:

Duration:

Query visualization of Display the the full name, and department number for those employees who works either in department 70 or 90 - Duration

Rows:

Query visualization of Display the the full name, and department number for those employees who works either in department 70 or 90 - Rows

Cost:

Query visualization of Display the the full name, and department number for those employees who works either in department 70 or 90 - Cost

Contribute your code and comments through Disqus.

Previous: Write a query in SQL to display the full name (first and last), job id and date of hire for those employees who was hired during November 5th, 2007 and July 5th, 2009.
Next: Write a query in SQL to display the full name (first and last name), salary, and manager number for those employees who is working under a manager.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming