w3resource

SQL SORTING and FILTERING on HR Database: Display 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. From the following table, write a SQL query to find those employees who works either in department 70 or 90. Return full name (first and last name), department id.

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 full name, and department number for those employees who works either in department 70 or 90 - Duration

Rows:

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

Cost:

Query visualization of Display 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 full name, and department number for those employees who works either in department 70 or 90 - Duration

Rows:

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

Cost:

Query visualization of Display 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: From the following table, write a SQL query to find those employees who were hired during November 5th, 2007 and July 5th, 2009. Return full name (first and last), job id and hire date.
Next: From the following table, write a SQL query to find those employees who work under a manager. Return full name (first and last name), salary, and manager 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

Ref: https://bit.ly/3xzB9dS