w3resource

PostgreSQL String() Function: Display a couple of columns which contain a character 'C' in a specific column after 2nd position


12. Write a query to display the first name, last name for the employees, which contain a letter 'C' to their last name at 3rd or greater position.

Sample Solution:

Code:

SELECT first_name, last_name 
FROM employees 
WHERE POSITION('C' IN last_name) > 2;

Sample table: employees


Output:

pg_exercises=# SELECT first_name, last_name
pg_exercises-# FROM employees
pg_exercises-# WHERE POSITION('C' IN last_name) > 2;
 first_name | last_name
------------+-----------
 Samuel     | McCain
(1 row)

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