Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
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.

Previous: Write a query to display the first word in the job title if the job title contains more than one words.
Next: Write a query that displays the first name and the character length of the first name for all employees whose name starts with the letters 'A', 'J' or 'M'. Give each column an appropriate label. Sort the results by the employees' first names.

What is the difficulty level of this exercise?