Skip to Main Content
SQL in a Nutshell, 3rd Edition
book

SQL in a Nutshell, 3rd Edition

by Kevin Kline
November 2008
Intermediate to advanced content levelIntermediate to advanced
591 pages
17h 28m
English
O'Reilly Media, Inc.
Content preview from SQL in a Nutshell, 3rd Edition

Numeric Scalar Functions

The list of official ANSI SQL numeric functions is rather small, and the different platforms provide supplementary mathematical and statistical functions. MySQL and PostgreSQL both support many of the ANSI standard functions. The other database platforms offer the same capabilities of numeric scalar functions through their own internally defined functions, but they do not share the same names as those declared by the SQL standard. The supported numeric functions and syntax are listed in Table 4-4.

Table 4-4. ANSI SQL numeric functions

Function

Usage

ABS

Returns the absolute value of a number.

BIT_LENGTH

Returns an integer value representing the number of bits in another value.

CEIL or CEILING

Rounds a noninteger value upward to the next greatest integer. Returns an integer value unchanged.

CHAR_LENGTH

Returns an integer value representing the number of characters in a string expression.

EXP

Raises a value to the power of the mathematical constant known as e.

EXTRACT

Allows the datepart to be extracted (YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, TIMEZONE_HOUR, or TIMEZONE_MINUTE) from a temporal expression.

FLOOR

Rounds a noninteger value downward to the next least integer. Returns an integer value unchanged.

LN

Returns the natural logarithm of a number.

MOD

Returns the remainder of one number divided into another.

OCTET_LENGTH

Returns an integer value representing the number of octets in another value. This value is the same as BIT_LENGTH / 8.

POSITION

Returns an integer value representing ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Effective SQL: 61 Specific Ways to Write Better SQL, First Edition

Effective SQL: 61 Specific Ways to Write Better SQL, First Edition

John L. Viescas, Douglas J. Steele, Ben G. Clothier
SQL in a Nutshell, 4th Edition

SQL in a Nutshell, 4th Edition

Kevin Kline, Regina O. Obe, Leo S. Hsu

Publisher Resources

ISBN: 9780596155322Errata Page