Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help with task 7 . MySQL Lab Instructions Before running queries, check the selected database matches the database indicated in the instructions. The Run
Please help with task
MySQL Lab Instructions
Before running queries, check the selected database matches the database indicated in the instructions.
The "Run Code" button will run the contents of the query.sql file only.
Complete each task in order and press the Run Test button for that specific task before moving on
Only select Calculate Grade when you are satisfied with your answer.
Scenario and Database Model: InstantRide
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 :
Drivers are essential for InstantRide, and the Driver Relationship team is responsible for their integration and success. The team requires all the driver detail in the system for creating a new dashboard. You need to SELECT all available data for the drivers and return back to the team.
Task : Query all the driver data from the DRIVERS table.
Task :
The Driver Relationship team also requests the joining dates of the drivers to create a timeline. In the table, you only need to return the joining date of the drivers. You need to only return the DRIVERSTARTDATE column inside a SELECT statement for the DRIVERS table.
Task : Query the start date for each driver.
Task :
The Driver Relationship team would like the DRIVERID and DRIVERRATING of drivers currently having a rating higher than in descending order.
Task : Query all drivers by their driver rating in descending order.
Task : Query all drivers with a rating higher than
Task :
The InstantRide User Satisfaction team is a core team for InstantRide, and they focus on increasing the customer satisfaction. They want to learn the travel time for each ride in the system. You need to return the USERID##and the TRAVELTIME column which is calculated using the TIMEDIFF function on the TRAVELENDTIME and the TRAVELSTARTTIME.
Task : Query the travel time for each ride.
Task :
User Satisfaction team wants to send monthly summaries for each user. They need the following details with the user ID:
The last day of the month when the users traveled most recently
One week after the last day of the month when the users traveled most recently
You need to return a threecolumn output with
USERID
LASTTRAVELMONTH
NOTIFICATION
You need to return a threecolumn output with USERID LASTTRAVELMONTH and NOTIFICATION, LASTTRAVELMONTH should be calculated using the MAX of the LASTDAY of the TRAVELENDTIME field. Similarly, NOTIFICATION should be calculated with DATEADD function to add one week.
Task : Query monthly summaries for each user.
Task :
The Marketing team of InstantRide wants to know that how many discounts have been offered for each ride. You need to calculate this information for each travel where a discount is applied and return two columns: TRAVELID and DISCOUNTAMOUNT##In addition, you need to return the calculation as a money value using the ROUND function to decimals.
Task : Calculate the total amount of discounts given.
Test Feedback:
Status: FAILED!
Check:
Test: Calculate the total amount of discounts given
Reason: The following error is preventing tests from completing: S: Unknown column 'DISCOUNTAMOUNT' in 'field list'
Error : ProgrammingError S Unknown column 'DISCOUNTAMOUNT' in 'field list'
The following was used for task :
SELECT
TRAVELID
ROUNDDISCOUNTAMOUNT, AS DISCOUNTAMOUNT
FROM TRAVELS
WHERE DISCOUNTAMOUNT ;
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