sql function related question! Hi, I need to create a function that accepts officer_id and returns the keyword Active or Inactive. If officer_id exists in the system it finds the status of either A or I. (nested if) if the officer is active(a) then based on the last digit of badge number, if last digit is between 0-5 it returns 'ACTIVE ON DESK'. else if the last digit of badge number is greater than 5, it returns 'ACTIVE ON DUTY' If officer is inactive(I ), it returns Inactive. If officer_id does not exist, it returns 'not existing officer' Please help me with this!

icon
Related questions
Question

sql function related question!

Hi, I need to create a function that accepts officer_id and returns the keyword Active or Inactive.

If officer_id exists in the system it finds the status of either A or I.
(nested if) if the officer is active(a) then based on the last digit of badge number, if last digit is between 0-5 it returns 'ACTIVE ON DESK'. else if the last digit of badge number is greater than 5, it returns 'ACTIVE ON DUTY'

If officer is inactive(I ), it returns Inactive.

If officer_id does not exist, it returns 'not existing officer'
Please help me with this!

 

 

 

OFFICER_ID LAST
111112 Shocks
111113 Busey
111114 Gants
111115 Hart
111116 Sands
FIRST
Pam
Gerry
Dale
Leigh
Ben
PREC BADGE
OCVW E5546A33
GHNT E5577D48
SBCH E5536N02
WAVE E5511J40
OCVW E5588R00
PHONE
S
SI
7574446767 A
7574446767 A
7574446767 A
7574446767 A
7574446767 I
Transcribed Image Text:OFFICER_ID LAST 111112 Shocks 111113 Busey 111114 Gants 111115 Hart 111116 Sands FIRST Pam Gerry Dale Leigh Ben PREC BADGE OCVW E5546A33 GHNT E5577D48 SBCH E5536N02 WAVE E5511J40 OCVW E5588R00 PHONE S SI 7574446767 A 7574446767 A 7574446767 A 7574446767 A 7574446767 I
Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

Hi thank you for the explanation! 

BTW, can you use oracle sql structure? Not MySQL.
It's a bit hard to understand

Solution
Bartleby Expert
SEE SOLUTION