Implement the missing code, denoted by ellipses. You may not modify the pre-existing code. Your professor gave the class a bonus task: Write a program that will check the answers for the latest test. The program will be given a table answers with the following columns: id - the unique ID of the question; correct_answer - the correct answer to the question, given as a string; given_answer - the answer given to the question, which can be NULL. Your task is to return the table with a column id and a column checks, where for each answers id the following string should be returned: "no answer" if the given_answer is empty; "correct" if the given_answer is the same as the correct_answer; "incorrect" if the given_answer is not empty and is incorrect. Order the records in the answer table by id. |
code>>
CREATE PROCEDURE testCheck()
SELECT id, IF (correct_answer = given_answer, 'correct', IF(given_answer IS NULL, 'no answer', 'incorrect')) AS checks
FROM answers
ORDER BY id;
'알고리즘 > codefightsDB' 카테고리의 다른 글
16>newsSubscribers (0) | 2019.03.13 |
---|---|
15>expressionsVerification (0) | 2019.03.13 |
13>securityBreach (0) | 2019.03.13 |
12>suspectsInvestigation2 (0) | 2019.03.13 |
11>suspectsInvestigation (0) | 2019.03.12 |