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_IDVehicle_NameVehicle_QuantityPurchasing_VehiclesSelling_VehiclesRelease_DateVehicle_Rating
140P129045802022-04-3080
190P4151801802022-01-2890.85
145P2202702902022-02-1880
90P710360802021-12-25180
45P63545-152021-10-1580
210P830160-602022-01-2895
185P102904504702022-04-1180

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_IDe raised to the power_of_Vehicle_ID
1406.327e+60
1903.28e+82
1459.39e+62
901.22e+39
4534934270792009135368
2101.59e+91
1852.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_Vehiclese raised to the power_of_PurchasingVehicles
4534934270792009135368
1801.489e+78
2701.81e+117
3602.218e+156
4534934270792009135368
1603.069e+69
4502.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_Ratinge raised to the power_of_vehiclerating
805.54e+34
90.852.855e+39
805.54e+34
1801.489e+78
805.54e+4
951.811e+41
805.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_Vehiclese raised to the power_of_SellingVehicles
805.54e+34
1801.489e+78
2908.818e+125
805.54e+34
-150
-600
4701.313e+204