Computer Science, asked by karthic05, 8 months ago

Write a query to display car id and number of times car taken for rental. Give an alias name to the number of times car taken for rental as 'NO_OF_TRIPS'. Sort the records based on car id in ascending order
sql

Answers

Answered by jaisonprem
26

Answer:

SELECT  car_id,count(car_id) FROM rentals

GROUP BY car_id

ORDER BY car_id ASC;

Answered by qwvilla
1
  • The STRUCTURED QUERY LANGUAGE (SQL) to display

car id and number of times car taken for rental is

SELECT car_id,count(car_id) FROM rentals

SELECT car_id,count(car_id) FROM rentalsGROUP BY car_id

We have to use the clause Select,from and Group By in this case.

  • The STRUCTURED QUERY LANGUAGE (SQL) to

name the number of times car taken for rental as 'NO_OF_TRIPS' is

Rename count(car_id) to NO_OF_TRIPS

We have to use the clause Rename in this case

  • The STRUCTURED QUERY LANGUAGE (SQL) to Sort the records based on car id in ascending order is

ORDER BY car_id ASC

We have to use the clause Order By in this case.

#SPJ3

Similar questions