Expressions in SQL: Expressions are used in SQL to retrieve and search by calculation of values in the database.
SELECT EMPLOYEES FROM GROUPS WHERE PERKS > MIN_PERKS + 500
Built-in functions in SQL: Built in functions are used for data type conversions and for other formatting purposes.
Types of built in functions defined in SQL:
TRANSLATE function: It is used to translate a string.
TRANSLATE (string USING tran)
TRIM function: It is used to trim leading occurrences of char.
TRIM (LEADING char FROM string)
To trim any trailing occurrences of char.
TRIM (TRAILING char FROM string)
To trim both leading and trailing occurrences of char:
TRIM (BOTH char FROM string)
UPPER function: It is used to convert a string to uppercase characters.
BIT_LENGTH function: It is used to find number of bits in a bit string.
CAST function: It is used to convert a data type.
CHAR_LENGTH: It is used to find length of a character string.
CONVERT function: It is used to convert a string.
CONVERT (string USING con)
CURRENT_DATE function: It is used to return current date.
CURRENT_TIME function: It is used to return current time with precision.
CURRENT_TIMESTAMP function: It is used to return current date and time with precision.
EXTRACT function: It is used to extract DAY, HOUR, etc. from a DATETIME value.
EXTRACT (part FROM source)
LOWER function: It is used to convert a string to lowercase characters.
OCTET_LENGTH function: It returns number of 8 bit bytes in a character string.
POSITION function: It specifies position where target string is found within source string.
POSITION (target IN source)
SUBSTRING function: It returns part of source string, starting at nth character, for a length of sting length.
SUBSTRING (source FROM n FOR length)
Null values in SQL: A null values is used to specify an unknown or a not applicable value in a database. It is specified by NULL.