w3resource

SQL SORTING and FILTERING on HR Database: Display the first and last name, and salary for those employees whose first name is ending with the letter m

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

10. From the following table, write a SQL query to find those employees whose first name ends with the letter ‘m’. Return the first and last name, and salary.

Sample table : employees


Sample Solution:

SELECT first_name, last_name, salary
 FROM employees
  WHERE first_name LIKE '%m';

Sample Output:

 first_name | last_name | salary
------------+-----------+---------
 Adam       | Fripp     | 8200.00
 Payam      | Kaufling  | 7900.00
 William    | Smith     | 7400.00
 William    | Gietz     | 8300.00
(4 rows)

Relational Algebra Expression:

Relational Algebra Expression: Display the first and last name, and salary for those employees whose first name is ending with the letter m.

Relational Algebra Tree:

Relational Algebra Tree: Display the first and last name, and salary for those employees whose first name is ending with the letter m.

Practice Online


HR database model

Query Visualization:

Duration:

Query visualization of Display the first and last name, and salary for those employees whose first name is ending with the letter m - Duration

Rows:

Query visualization of Display the first and last name, and salary for those employees whose first name is ending with the letter m - Rows

Cost:

Query visualization of Display the first and last name, and salary for those employees whose first name is ending with the letter m - Cost

Contribute your code and comments through Disqus.

Previous: From the following table, write a SQL query to find those employees whose salary is in the range 9000,17000 (Begin and end values are included). Return full name, contact details and salary.
Next: From the following table, write a SQL query to find those employees whose salary is not in the range 7000 and 15000 (Begin and end values are included). Sort the result-set in ascending order by the full name (first and last). Return full name and salary.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



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