Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to select all columns from the table named 'students'.
Intro to Computing
SELECT [1] FROM students; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using words like 'all' or 'columns' instead of the symbol *.
Leaving the blank empty.
✗ Incorrect
In SQL, * means select all columns from the table.
2fill in blank
mediumComplete the code to filter records where the age is greater than 18.
Intro to Computing
SELECT * FROM users WHERE age [1] 18;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' which means exactly equal.
Using '<' which means less than.
✗ Incorrect
The symbol > means 'greater than' in SQL conditions.
3fill in blank
hardFix the error in the SQL statement to count the number of rows in the 'orders' table.
Intro to Computing
SELECT COUNT([1]) FROM orders; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using words like 'all' or 'rows' which are not valid in COUNT.
Using a column name that might have NULL values.
✗ Incorrect
Using COUNT(*) counts all rows in the table.
4fill in blank
hardFill both blanks to create a table named 'employees' with columns 'id' as integer and 'name' as text.
Intro to Computing
CREATE TABLE employees (id [1], name [2]);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'NUMBER' which is not standard SQL type here.
Using 'VARCHAR' without specifying length.
✗ Incorrect
INTEGER is used for whole numbers, and TEXT is used for text strings in SQL.
5fill in blank
hardFill all three blanks to select 'name' and 'age' from 'people' where 'age' is less than 30.
Intro to Computing
SELECT [1], [2] FROM people WHERE [3] < 30;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'person' which is not a column name.
Mixing up the order of columns.
✗ Incorrect
You select the columns name and age, and filter where age is less than 30.