Answered step by step
Verified Expert Solution
Question
1 Approved Answer
InstantRide is the new ride sharing application in the city and it has just started its operations. With the help of the InstantRide mobile application,
InstantRide is the new ride sharing application in the city and it has just started its operations. With the help of the InstantRide mobile application, the users request a ride with their location. Drivers and cars are assigned to the request; and then the driver picks up the user to ride their requested location. Information for the users, drivers and cars are stored in the database as well as the travel transactions.
In the USERS table, information for the users are stored with their first name, last name and email:
USERS Table
USERS Table
In the DRIVERS table, all the drivers in the InstantRide are stored with their name, driving license number and check and rating information:
DRIVERS Table
DRIVERS Table
In the CARS table, all the cars in the InstantRide system are kept with the license plate, model and year:
CARS Table
CARS Table
Finally, the transactions of the rides are stored in the TRAVELS table. For each travel, start and end time with location are stored. In addition, the involved driver, car and user are listed for each drive. Price and discount information are also available in the database:
TRAVELS Table
TRAVELS Table
You are assigned as the database administrator to collect and manage transactional data of the InstantRide operations. Your main task is to create SQL scripts to help other teams to retrieve the requested data. In the following activities, you will create the scripts, run against the database and send the result to the corresponding teams.
Task :
The InstantRide Driver Relationship team wants the details of the drivers and the number of cars they use. Calculate the count of the CARID field in the TRAVELS table and return a table grouped by DRIVERID and in descending order by the calculated COUNT column, displayed as CARS
Task : Calculate the number of cars each driver uses.
Task :
The InstantRide Driver Relationship team requires the detail of the drivers who has used more than one car for rides more than twice. Send them the DRIVERID with the calculated COUNT of used cars, displayed as CARS in decreasing order.
Task : Query the drivers that have used more than one car more than once.
Task :
The InstantRide Marketing team is planning to create a heatmap of the start locations of the travels in InstantRide. The team requires the DISTINCT TRAVELSTARTLOCATION values for all travels in the system.
Task : Query all the distinct start locations.
Task :
The InstantRide User Satisfaction team requires the average and maximum number of rides users have taken so far with InstantRide. In addition, they would like to know the total number of travels. However, they need these details with the corresponding column names Average, Maximum and Total by using the AVG, MAX and SUM functions. In order to accomplish this, you will first need to create a derived table from the TRAVELS table to pass the TRAVELID count to the three mathematical functions.
Task : Query the average, maximum, and total number of rides users have taken.
Task :
The InstantRide Driver Relationship team wants to learn how many travels each driver has done in the month of October. You need to send them the DRIVERID and two calculated columns: DAY and RIDES.The DAY column is calculated using the DAY function with the TRAVELSTARTTIME as the argument. The RIDES column is calculated by using the COUNT function to determine the number of rides given for each day. Filter the results with the MONTH function.
Task : Query all travels given by drivers in the month of October.
Task :
The InstantRide User Satisfaction team received a phone call from a user who might have left her wallet in the car. She indicated that the license plate of the car was starting with BB but unfortunately, she could not remember the full license plate number. The team wants to get all travel information for the cars with the license plate starting with BB You need to return all travel data from the TRAVELS table for the CARID which has a plate number compared with SUBSTR and UPPER functions.
Task : Get all travel information for cars with a license plate starting in BB
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started