0
0
SQLquery~10 mins

Variables and SET statements 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 declare a variable named @count as an integer.

SQL
DECLARE [1] INT;
Drag options to blanks, or click blank then click option'
Acount
B$count
C#count
D@count
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting the '@' symbol before the variable name.
Using invalid characters like '#' or '$' in variable names.
2fill in blank
medium

Complete the code to set the value 10 to the variable @count.

SQL
SET [1] = 10;
Drag options to blanks, or click blank then click option'
Acount
B#count
C@count
D$count
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the '@' symbol when setting the variable.
Using the variable name without declaration.
3fill in blank
hard

Fix the error in the code to correctly set the variable @total to the sum of 5 and 7.

SQL
SET [1] = 5 + 7;
Drag options to blanks, or click blank then click option'
Atotal
B@total
C#total
D$total
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names without '@' in SET statements.
Using invalid variable prefixes like '#' or '$'.
4fill in blank
hard

Fill both blanks to declare a variable @name as VARCHAR(50) and set it to 'Alice'.

SQL
DECLARE [1] [2];
SET @name = 'Alice';
Drag options to blanks, or click blank then click option'
A@name
BVARCHAR(50)
CINT
DTEXT
Attempts:
3 left
💡 Hint
Common Mistakes
Using INT or TEXT instead of VARCHAR(50) for string variables.
Forgetting '@' in variable declaration.
5fill in blank
hard

Fill all three blanks to declare @score as INT, set it to 100, and then increase it by 20.

SQL
DECLARE [1] [2];
SET [3] = 100;
SET @score = @score + 20;
Drag options to blanks, or click blank then click option'
A@score
BINT
DVARCHAR(10)
Attempts:
3 left
💡 Hint
Common Mistakes
Using VARCHAR type for numeric variables.
Forgetting '@' in variable names during SET.