select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Unsupported versions: 7.0 / 6.5 / 6.4
Historical version. PostgreSQL 6.5 reached end of support in June 2004. See the current manual for supported releases.

Chapter 5. Functions

Describes the built-in functions available in Postgres.

Many data types have functions available for conversion to other related types. In addition, there are some type-specific functions. Some functions are also available through operators and may be documented as operators only.

SQL Functions

SQL functions” are constructs defined by the SQL92 standard which have function-like syntax but which can not be implemented as simple functions.

Table 5-1. SQL Functions

Function Returns Description Example
COALESCE(list) non-NULL return first non-NULL value in list COALESCE(r"le>, c2 + 5, 0)
IFNULL(input,non-NULL substitute) non-NULL return second argument if first is NULL IFNULL(c1, 'N/A')
CASE WHEN expr THEN expr [...] ELSE expr END expr return expression for first true clause CASE WHEN c1 = 1 THEN 'match' ELSE 'no match' END

Report a documentation issue

Read the upstream documentation. For corrections, first check the current manual.