EXP Function - SQL
Overview
The EXP function in SQL returns the value of e raised to the power of a given numeric expression. It is useful for exponential calculations.
Example:
SELECT
EXP(1)
Syntax:
SELECT
EXP(numeric_expression)
numeric_expression
is the exponent to which the base e is raised.
Sample Data:
first_name | vacation_days |
---|---|
Frank | 5 |
Jane | 2 |
Ashley | 3 |
Glenn | -3 |
Kelly | 2 |
Richard | -7 |
George | 2 |
Kyle | 1 |
James | -2 |
Gustavo | -10 |
Example: Hard-coded value
In this example, we are returning e raised to the power of 1. Since e is equal to 2.718281828459045, that is the final output because to the power of 1 just equals itself.
Example: Query without the WHERE Statement
In this example, we are returning the value of e raised to the power of the vacation_days column.
Example: Query with the WHERE Statement
In this example, we are returning the value of e raised to the power of the vacation_days column where the first_name equals Glenn.