The Driver Relationship team wants to arrange workshops and education materials to the drivers. However, the team wants to create clusters of the drivers based on their experience in InstantStay. To collect these detail, you will need to create a SQL function called DRIVER_STATUS to determine the level of the driver as follows: MASTER: more than 4 travels PRO: more than 2 travels ROOKIE: 2 or less travels In addition, run the function to verify it works as expected and send them back the driver levels. Task: Create the DRIVER_STATUS function to create clusters of drivers based on experience.
The Driver Relationship team wants to arrange workshops and education materials to the drivers. However, the team wants to create clusters of the drivers based on their experience in InstantStay. To collect these detail, you will need to create a SQL function called DRIVER_STATUS to determine the level of the driver as follows: MASTER: more than 4 travels PRO: more than 2 travels ROOKIE: 2 or less travels In addition, run the function to verify it works as expected and send them back the driver levels. Task: Create the DRIVER_STATUS function to create clusters of drivers based on experience.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Task 2:
The Driver Relationship team wants to arrange workshops and education materials to the drivers. However, the team wants to create clusters of the drivers based on their experience in InstantStay. To collect these detail, you will need to create a SQL function called DRIVER_STATUS to determine the level of the driver as follows:
- MASTER: more than 4 travels
- PRO: more than 2 travels
- ROOKIE: 2 or less travels
In addition, run the function to verify it works as expected and send them back the driver levels.
Task: Create the DRIVER_STATUS function to create clusters of drivers based on experience.
THIS CODE YOU SEE HERE IS WRONG. THERE IS AN ERROR AT LINE 2
DELIMITER <
CREATE FUNCTION DRIVER_STATUS(int DRIVERID)
RETURNS VARCHAR
BEGIN
DECLARE
//to store number of travels
Count int;
//to store level
Level VARCHAR;
//Selects according to passed value
SELECT COUNT(*) INTO Level FROM TRAVEL WHERE DRIVER_ID = DRIVERID;
//returns level
IF( Count > 4) THEN
RETURN "MASTER";
ELSE IF (Count > 2) THEN
RETURN "PRO"
ELSE IF (Count <= 2) THEN
RETURN "ROOKIE";
END
DELIMITER ;

Transcribed Image Text:DRIVER_ID
DRIVER_FIRST_NAME DRIVER_LAST_NAME DRIVER_DRIVING_LICENSE_ID
DRIVER_START_DATE DRIVER_DRIVING_LICENSE_CHECKED
DRIVER_RATING
2001
Willie
Butler
1874501
2019-09-12
1
4.4
2002
Justin
Howard
1953853
2019-09-09
1
4.8
2003
Anthony
Walker
1735487
2019-09-15
1
3.5
2004
Ece
Yilmaz
1734747
2019-08-15
1

Transcribed Image Text:Instructions Page 2 of 4
+
query.sql
1 THIS CODE YOU SEE HERE IS WRONG. THERE IS AN ERROR AT LINE 2
3 DELIMITER <
Task 2:
4 CREATE FUNCTION DRIVER_STATUS(int DRIVERID)
5 RETURNS VARCHAR
The Driver Relationship team wants to arrange workshops and education materials to the
6
drivers. However, the team wants to create clusters of the drivers based on their
7 BEGIN
8 DECLARE
experience in InstantStay. To collect these detail, you will need to create a SQL function
9 //to store number of travels
called DRIVER_STATUS to determine the level of the driver as follows:
10 Count int;
11 //to store level
• MASTER: more than 4 travels
12 Level VARCHAR;
13
• PRO: more than 2 travels
| 14 //Selects according to passed value
15 SELECT COUNT (*) INT0 Level FROM TRAVEL WHERE DRIVER_ID = DRIVERID;
• ROOKIE: 2 or less travels
16
17 //returns level
|18 IF( Count > 4) THEN
In addition, run the function to verify it works as expected and send them back the driver
levels.
DETUDAL IMAS TEDIL.
Task
9 SQL Viewer
+
Create the DRIVER_STATUS function to create clusters of drivers based on
experience.
0.00
out of
10.00
O out of 1 checks passed. Review the results below for more details.
ERROR 1064 (42000) at line 2: You have an error in your SQL syntax; check the manual that corresponds to
your MYSQL server version for the right syntax to use near 'int DRIVERID) RETURNS VARCHAR BEGIN DECLARE
//to store number of travels Count' at line 1
Checks
SQL Database Test • Incomplete
>
Create the DRIVER_STATUS function
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education