SQL Dialects Reference/Functions and expressions/Misc expressions

From Wikibooks, the open-content textbooks collection

Jump to: navigation, search

[edit] String functions

This page includes comparison tables which can be big and complex.

While it's perfectly all right to view them in their complete state, it is recommended to install a comparison tables extension that would allow to select particular columns of interest for comparison.

Function Since SQL Standard DB2 SQLite MySQL PostgreSQL Firebird Virtuoso Oracle MSSQL Linter
Convert data from one data type to another 92 CAST()  ?  ?  ? CAST(expression AS type) or  :: CAST(expression AS type)  ? CAST(), TO_* CAST(), CONVERT() CAST(expression as type)
CASTexpression as type
TO_CHAR
TO_NUMBER
TO_DATE
Return the first non-NULL value from a list of values 92 COALESCE(val1, val2, ...) COALESCE(val1, val2)  ? COALESCE(val1, val2) COALESCE(val1, val2) COALESCE(val1, val2)  ? COALESCE(val1, val2) COALESCE(val1, val2, ...), ISNULL(val1, val2) NVL(val1,val2)
COALESCE(val1, val2, ...)
Return NULL if two values are equal 92 NULLIF(val1, val2)  ?  ?  ? NULLIF(val1, val2)  ?  ? NULLIF(val1, val2) NULLIF(val1, val2) NULLIF(val1, val2)