Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

LN function - Amazon Redshift

LN function

Returns the natural logarithm of the input parameter.

Synonym of DLOG1 function.

Syntax

LN(expression)

Argument

expression

The target column or expression that the function operates on.

Note

This function returns an error for some data types if the expression references an Amazon Redshift user-created table or an Amazon Redshift STL or STV system table.

Expressions with the following data types produce an error if they reference a user-created or system table. Expressions with these data types run exclusively on the leader node:

  • BOOLEAN

  • CHAR

  • DATE

  • DECIMAL or NUMERIC

  • TIMESTAMP

  • VARCHAR

Expressions with the following data types run successfully on user-created tables and STL or STV system tables:

  • BIGINT

  • DOUBLE PRECISION

  • INTEGER

  • REAL

  • SMALLINT

Return type

The LN function returns the same type as the input expression.

Examples

To return the natural logarithm or base e logarithm of the number 2.718281828, use the following example.

SELECT LN(2.718281828); +--------------------+ | ln | +--------------------+ | 0.9999999998311267 | +--------------------+

Note that the answer is nearly equal to 1.

The following example uses the TICKIT sample database. For more information, see Sample database.

To return the natural logarithm of the values in the userid column in the USERS table, use the following example.

SELECT username, LN(userid) FROM users ORDER BY userid LIMIT 10; +----------+--------------------+ | username | ln | +----------+--------------------+ | JSG99FHE | 0 | | PGL08LJI | 0.6931471805599453 | | IFT66TXU | 1.0986122886681098 | | XDZ38RDD | 1.3862943611198906 | | AEB55QTM | 1.6094379124341003 | | NDQ15VBM | 1.791759469228055 | | OWY35QYB | 1.9459101490553132 | | AZG78YIP | 2.0794415416798357 | | MSD36KVR | 2.1972245773362196 | | WKW41AIW | 2.302585092994046 | +----------+--------------------+
PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.