w3resource
SQL exercises

SQL SORTING and FILTERING on HR Database: Display the first and last name, department number for those employees who holds a letter s as a 3rd character in their first name

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

19. Write a query in SQL to display the first and last name, and department number for those employees who holds a letter s as a 3rd character in their first name.

Sample table : employees


Sample Solution:

SELECT first_name,last_name, department_id
 FROM employees
  WHERE first_name LIKE '__s%';

Sample Output:

 first_name  | last_name | department_id
-------------+-----------+---------------
 Jose Manuel | Urman     |           100
 Jason       | Mallin    |            50
 Joshua      | Patel     |            50
 Lisa        | Ozer      |            80
 Susan       | Mavris    |            40
(5 rows)

Practice Online


HR database model

Query Visualization:

Duration:

Query visualization of Display the first and last name, department number for those employees who holds a letter s as a 3rd character in their first name - Duration

Rows:

Query visualization of Display the first and last name, department number for those employees who holds a letter s as a 3rd character in their first name - Rows

Cost:

Query visualization of Display the first and last name, department number for those employees who holds a letter s as a 3rd character in their first name - Cost

Contribute your code and comments through Disqus.

Previous: Write a query in SQL to display the full name (first name and last name), hire date, commission percentage, email and telephone separated by '-', and salary for those employees who earn the salary above 11000 or the seventh digit in their phone number equals 3 and make the result set in a descending order by the first name.
Next: Write a query in SQL to display the employee ID, first name, job id, and department number for those employees who is working except the departments 50,30 and 80.

What is the difficulty level of this exercise?



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