MySQL Tutorial

PostgreSQL INITCAP() function

INITCAP() function

The PostgreSQL initcap() function is used to convert the first letter of each word to upper case and the remaining to lower case.



PostgreSQL Version: 9.3

Pictorial Presentation of PostgreSQL INITCAP() function

Pictorial presentation of postgresql initcap function

Example: PostgreSQL INITCAP() function:

In the example below the initcap function returns to convert the first character or each word in capital and rest are in small letter.


AS "First Character of each word Capital";

Sample Output:

 First Character of each word Capital
 Rabindranath Tagore
(1 row)

Sample Table: employees

Example of PostgreSQL INITCAP() function using column with nested functions:

If we want to display the first_name, last_name and name in lower case and name in proper case i.e. first letter of each word in capital for those employees who belongs to the department which ID 100, from the employees table, the following sql statement can be used:


SELECT first_name, last_name,
concat(lower(first_name),' ', lower(last_name)) "Name of Employee in lower case",
initcap(concat(first_name,' ', last_name)) "Proper Name"
FROM employees
WHERE department_id=100;

Sample Output:

 first_name  | last_name | Name of Employee in lower case |    Proper Name
 Nancy       | Greenberg | nancy greenberg                | Nancy Greenberg
 Daniel      | Faviet    | daniel faviet                  | Daniel Faviet
 John        | Chen      | john chen                      | John Chen
 Ismael      | Sciarra   | ismael sciarra                 | Ismael Sciarra
 Jose Manuel | Urman     | jose manuel urman              | Jose Manuel Urman
 Luis        | Popp      | luis popp                      | Luis Popp
(6 rows)

ankara escort