|
|
Using Scalar Functions
Scalar functions operate on expressions or on a single value received from a
SELECTstatement.Some of the scalar functions available are:
The complete list of scalar functions can be found in the Mimer SQL Reference Manual, About Scalar Functions.
Examples of Scalar Functions
The following are examples that illustrate how the scalar functions may be used:
List all currencies that contain the letters "AU" in upper or lower case:
SELECT currency FROM currencies WHERE LOWER(currency) LIKE '%au%';Returns:
Note: Alternatively, a case insensitive collation can be used to get the same result.
SELECT currency FROM currencies WHERE currency COLLATE english_1 LIKE '%au%';Find the position of the first space character in the formats column:
SELECT format, POSITION(' ' IN format) FROM formats;Returns:
FORMAT Audio CD Cassette DVD Audio Vinyl Audio Cassette Audio CD Hardcover Paperback DVD Video VideoAppend the word "Currency" to the currencies (without trailing spaces):
SELECT TRIM(TRAILING FROM currency) || ' Currency' FROM currencies WHERE code LIKE 'A%';Returns:
UAE Dirhams Currency Afghanis Currency Leke Currency Armenian Drams Currency Netherlands Antillian Guilders Currency Kwanza Currency ...Remove both leading and trailing spaces from the currencies and convert to uppercase; and get the significant length (in characters):
SELECT UPPER(TRIM(currency)), CHAR_LENGTH(TRIM(currency)) FROM currencies;Returns:
Find the country that sounds the same as "ASTRALYA":
SELECT country FROM countries WHERE SOUNDEX(country) = SOUNDEX('astralya');Returns:
Extract the first 5 characters from each format:
SELECT SUBSTRING(format FROM 1 FOR 5) FROM formats;Returns:
|
Mimer Information Technology AB Voice: +46 18 780 92 00 Fax: +46 18 780 92 40 info@mimer.se |
|
|