w3resource

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.

What is the difficulty level of this exercise?



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