Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to start an IF block in a SQL procedure.
SQL
IF [1] THEN
-- some statements
END IF; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using assignment operator ':=' instead of comparison.
Using '==' which is not valid in SQL.
✗ Incorrect
In SQL procedures, the IF condition uses a boolean expression like 'x > 10'.
2fill in blank
mediumComplete the code to add an ELSE block in a SQL procedure.
SQL
IF x > 0 THEN SET result = 'Positive'; [1] SET result = 'Non-positive'; END IF;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using ELSEIF or ELSIF which are for else-if conditions, not else alone.
Writing ELSE IF as two words which is invalid syntax.
✗ Incorrect
The ELSE keyword starts the else block in SQL procedures.
3fill in blank
hardFix the error in the IF statement condition in this SQL procedure code.
SQL
IF [1] THEN SET status = 'Valid'; END IF;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using assignment ':=' instead of comparison.
Using '==' which is not valid in SQL.
✗ Incorrect
The IF condition must be a boolean expression like 'score > 100'.
4fill in blank
hardFill both blanks to complete the IF-ELSEIF structure in a SQL procedure.
SQL
IF score [1] 90 THEN SET grade = 'A'; [2] score > 80 THEN SET grade = 'B'; END IF;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' in the first blank.
Using 'IF' instead of 'ELSEIF' for the second blank.
✗ Incorrect
The first blank is a comparison operator '>', the second blank is the keyword 'ELSEIF'.
5fill in blank
hardFill all three blanks to complete the IF-ELSEIF-ELSE structure in a SQL procedure.
SQL
IF age [1] 18 THEN SET status = [2]; [3] SET status = 'Minor'; END IF;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>=' in the first blank.
Missing quotes around 'Adult' in the second blank.
Using ELSEIF instead of ELSE in the third blank.
✗ Incorrect
The first blank is '>=' to check age 18 or older, second blank is the string 'Adult', third blank is 'ELSE' for the else block.