The InstantRide Finance team wants to know the average discount amounts for each car in the InstantRide. Calculate the average discount amount as monetary value for the travels where a discount is applied. You need to create a subquery over the TRAVELS table to retrieveCAR_ID andDISCOUNT_AMOUNT, calculated with2 decimals using the ROUND function.
To calculate the DISCOUNT_AMOUNT, multiply the TRAVEL_PRICE by the TRAVEL_DISCOUNT where the TRAVEL_DISCOUNT value is not NULL. Round the result to2 decimals.
Then you can use this subquery to get theCAR_ID andAVG of DISCOUNT_AMOUNT values, once again using the ROUND function on the average results. Group the results by the CAR_ID. UseCAR_ID andDISCOUNT_AMOUNT as column aliases and return it back to the Finance team.
Task: Calculate the average discount for each car.
You need to first calculate the discount amount for each car using the ROUND function. Then use a subquery to calculate average discount amount using AVG function.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here