|| 字符串拼接
語法
string || string
示例
'Post' || 'greSQL' -- 返回PostgreSQL
length() 字符串的長度
語法
length(string)
示例
length('Odoo') -- 返回4
LIKE 模式匹配
語法
string LIKE pattern
示例
’abc’ LIKE ’abc’ -- 返回true
’abc’ LIKE ’a%’ -- 返回true
to_char() 把時間戳轉(zhuǎn)換成字符串
語法
to_char(timestamp, text)
示例
to_char(create_date, 'YYYY/MM/DD')
to_char(create_date, ’HH12:MI:SS’)
to_date() 把字符串轉(zhuǎn)換成日期
語法
to_date(text, text)
示例
to_date(’05 Jan 2015’,’DD Mon YYYY’)
to_timestamp() 把字符串轉(zhuǎn)換成時間戳
語法
to_timestamp(text, text)
示例
to_timestamp(’05 Jan 2015’, ’DD Mon YYYY’)
CASE 條件表達(dá)式, 類似于其他編程語言中的if/else
語法1
CASE WHEN condition THEN result [WHEN ...] [ELSE result] END
示例1
CASE WHEN gender='male' THEN '程序猿' ELSE '程序媛' END
語法2(簡化形式)
CASE expression WHEN value THEN result [WHEN ...] [ELSE result] END
示例2
CASE gender WHEN 'male' THEN '程序猿' ELSE '程序媛' END
COALESCE() 返回第一個非NULL的參數(shù)拯坟,所有參數(shù)均為NULL時則返回NULL
語法
COALESCE(value [, ...])
示例
COALESCE(actual_qty,0) as actual_qty
NULLIF() 如果value1與value2相等則返回NULL, 否則返回value1
語法
NULLIF(value1, value2)
示例
NULLIF(value, ’(none)’)
ascii() 將參數(shù)的第一個字符轉(zhuǎn)換為ASCII碼
語法
ascii(string)
示例
ascii(’x’) -- 返回120
chr() 將ASCII碼轉(zhuǎn)換為字符
語法
chr(int)
示例
chr(65) -- 返回A