| | string concatenation
Grammar
string | | String
Example
' Post ' | | ' Gresql '--Return to PostgreSQL
length () string
Grammar
Length (String)
Example
Length (' Odoo ')--return 4
Like pattern matching
Grammar
String like pattern
Example
' abc ' LIKE ' abc '--Return True
' abc ' like ' a% '--Returns True
to_char () converts a timestamp to a string
Grammar
To_char (timestamp, text)
Example
To_char (create_date, ' yyyy/mm/dd ')
To_char (create_date, ' HH12:MI:SS ')
to_date () converts a string to a date
Grammar
To_date (text, text)
Example
To_date (' Jan ', ' DD Mon YYYY ')
To_timestamp () converts a string to a timestamp
Grammar
To_timestamp (text, text)
Example
To_timestamp (' Jan ', ' DD Mon YYYY ')
Case Conditional Expression, similar to If/else in other programming languages
Syntax 1
case when condition and result [when ...] [ELSE result] END
Example 1
case where gender= ' male ' Then ' program Ape ' ELSE ' program Yuan ' END
Syntax 2 (simplified form)
Case expression "When" value then "result [when ...] [ELSE result] END
Example 2
Case gender if ' male ' then ' program Ape ' ELSE ' program Yuan ' END
COALESCE () returns the first non-null argument, NULL is returned when all parameters are null
Grammar
Coalesce (value [, ...])
Example
COALESCE (actual_qty,0) as Actual_qty
nullif () returns null if value1 is equal to value2, otherwise returns value1
Grammar
Nullif (value1, value2)
Example
Nullif (Value, ' (none) ')
ASCII () converts the first character of a parameter to an ASCII code
Grammar
ASCII (String)
Example
ASCII (' x ')--Returns 120
chr () converts ASCII code to characters
Grammar
Chr (int)
Example
Chr (65)--Return a
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
PostgreSQL Common functions