PostgreSQL Restricting and Sorting Data: Display the last name of employees whose name have exactly six characters
7. Write a query to display the last name of employees whose name contain exactly six characters.
Sample Solution:
Code:
SELECT last_name
FROM employees
WHERE last_name LIKE '______';
Sample table: employees
Output:
pg_exercises=# SELECT last_name pg_exercises-# FROM employees pg_exercises-# WHERE last_name LIKE '______'; last_name ----------- Hunold Austin Faviet Tobias Himuro Landry Markle Bissot Marlow Mallin Rogers Ladwig Stiles Davies Vargas Tucker McEwen Sewall Greene Hutton Taylor Taylor Fleaur Cabrio McCain Feeney Whalen Mavris (28 rows)
Practice Online
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a query to display the last name, job, and salary for all those employees who hasn't worked as a Programmer or a Shipping Clerk, and not drawing the salary $4,500, $10,000, or $15,000.
Next: Write a query to display the last name of employees having 'e' as the third character.
What is the difficulty level of this exercise?
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/postgresql-exercises/restricting-and-sorting-data/restricting-and-sorting-data-exercise-7.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics