In: Computer Science
Print the total amount, the average dollar value of service visits (parts and labour costs) and the number of those visits for Acura, Mercedes and Jaguar car makes that are sold between September 2015 and December 2018 inclusive
Solution)
Note: I have used Showroom as the name of the Table and used
attribute names of my own because it was not mentioned in the
question.
Query:
SELECT SUM(amount),AVG(service_cost),COUNT(no_of_visits)
FROM Showroom
WHERE (MAKE=' Acura' OR MAKE=' Mercedes' OR MAKE='Jaguar ')
AND
( Sold_On IN BETWEEN '9/1/2015' AND '12/31/2018') ;
Explaination:
1.In the above query first we are checking for the condition that
the car is sold in between September 2015 to December 2018 or
not.
2.If yes then we are checking for the make ,that if the make of the
cars sold between this time is either Acura,Mercedes,or Jaguar or
not.
3.After this we get our required table of cars which are of
particular make and sold between the given time period.
4.Now we have to simply print or select the required things from
the table.
5. We select the Sum of the amount of these cars and average of the
cost of service on these cars and count the number of visits a
customer has visited the showroom for buying these cars .
I HOPE YOU LIKE THIS ANSWER PLEASE DO UP VOTE THANK YOU.