Home » EXP Function in SQL

EXP Function in SQL

by Online Tutorials Library

EXP Function in SQL

The EXP is a SQL function of mathematics which returns e raised to the power of given number.

Syntax of EXP Function

In the EXP syntax, we have to pass that decimal number whose e raised value we want to return.

In the Structured Query Language, we can also use the EXP function with the field of the table as shown in the following block:

In this syntax, we have to define the name and column of that table on which we want to perform the EXP function.

Examples of EXP function

Example 1: This example returns the e raised to the power of the specified number:

Output:

e_power_of_360
7.389056

Example 2: This example returns the e raised to the power of the specified number:

Output:

e_power_of_180
1.589e+78

Example 3: This example returns the e raised to the power of 90:

Output:

e_power_of_90
1.22e+39

Example 4: This example returns the e raised to the power of -45:

Output:

e_power_of_-45
0

Example 5: This example returns the e raised to the power of the given expression:

Output:

e_power_of_Expression
1.142e+26

Example 6: This example uses the EXP function with the SQL table.

In this example, we will create the new table through which we will perform the EXP function on the columns:

The following shows the syntax to create the new table in SQL:

The following CREATE statement creates the Vehicle_Details table for storing the details of purchasing and selling vehicles:

The following multiple INSERT queries insert the records of vehicles with their quantity, and number of selling and purchasing vehicles into the Vehicle_Details table:

The following SELECT statement displays the inserted records of the above Vehicle_Details table:

Vehicle_ID Vehicle_Name Vehicle_Quantity Purchasing_Vehicles Selling_Vehicles Release_Date Vehicle_Rating
140 P1 290 45 80 2022-04-30 80
190 P4 15 180 180 2022-01-28 90.85
145 P2 20 270 290 2022-02-18 80
90 P7 10 360 80 2021-12-25 180
45 P6 35 45 -15 2021-10-15 80
210 P8 30 160 -60 2022-01-28 95
185 P10 290 450 470 2022-04-11 80

Query 1: The following SELECT query uses the EXP function with the Vehicle_ID column of the above Vehicle_Details table:

This query shows the e raised to the power of vehicle id of each vehicle.

Output:

Vehicle_ID e raised to the power_of_Vehicle_ID
140 6.327e+60
190 3.28e+82
145 9.39e+62
90 1.22e+39
45 34934270792009135368
210 1.59e+91
185 2.21e+80

Query 2: The following SELECT query uses the EXP function with the Purchasing_Vehicles column of the above Vehicle_Details table:

This query shows the e raised to the power of purchasing vehicles.

Output:

Purchasing_Vehicles e raised to the power_of_PurchasingVehicles
45 34934270792009135368
180 1.489e+78
270 1.81e+117
360 2.218e+156
45 34934270792009135368
160 3.069e+69
450 2.707e+195

Query 3: The following SELECT query uses the EXP function with the Vehicle_Rating column of the above Vehicle_Details table:

This query shows the e raised to the power of rating of each vehicle from the above table.

Output:

Vehicle_Rating e raised to the power_of_vehiclerating
80 5.54e+34
90.85 2.855e+39
80 5.54e+34
180 1.489e+78
80 5.54e+4
95 1.811e+41
80 5.54e+34

Query 4: The following SELECT query uses the EXP function with the and Purchasing_Vehicles and Selling_Vehicles column of the above Vehicle_Details table:

This query shows the e raised to the power of selling Vehicles of each vehicle.

Output:

Selling_Vehicles e raised to the power_of_SellingVehicles
80 5.54e+34
180 1.489e+78
290 8.818e+125
80 5.54e+34
-15 0
-60 0
470 1.313e+204

You may also like