0
0
SQLquery~10 mins

IF-ELSE in procedures in SQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
Ax > 10
Bx = 10
Cx := 10
Dx == 10
Attempts:
3 left
💡 Hint
Common Mistakes
Using assignment operator ':=' instead of comparison.
Using '==' which is not valid in SQL.
2fill in blank
medium

Complete 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'
AELSE IF
BELSEIF
CELSIF
DELSE
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.
3fill in blank
hard

Fix 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'
Ascore > 100
Bscore = 100
Cscore := 100
Dscore == 100
Attempts:
3 left
💡 Hint
Common Mistakes
Using assignment ':=' instead of comparison.
Using '==' which is not valid in SQL.
4fill in blank
hard

Fill 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'
A>
BELSEIF
CIF
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' in the first blank.
Using 'IF' instead of 'ELSEIF' for the second blank.
5fill in blank
hard

Fill 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'
A>=
B'Adult'
CELSE
D<
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.