Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to select all columns from the sales table.
dbt
SELECT [1] FROM sales Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using words like 'all' or 'columns' instead of '*'
Leaving the SELECT statement incomplete
✗ Incorrect
The asterisk (*) selects all columns in SQL queries.
2fill in blank
mediumComplete the code to filter sales where amount is greater than 100.
dbt
SELECT * FROM sales WHERE amount [1] 100
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>'
Using '=' which checks for equality
✗ Incorrect
The '>' operator filters rows where amount is greater than 100.
3fill in blank
hardFix the error in the code to calculate total sales per product.
dbt
SELECT product_id, SUM([1]) FROM sales GROUP BY product_id Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Summing product_id which is an identifier
Summing price instead of quantity
✗ Incorrect
SUM should be applied to the quantity column to get total sales count.
4fill in blank
hardFill both blanks to create a dictionary of product sales where sales are above 50.
dbt
sales_dict = { [1]: [2] for [1] in products if sales[[1]] > 50 } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quantity as key instead of product_id
Using product as key but not matching loop variable
✗ Incorrect
Use product_id as key and sales as value for products with sales over 50.
5fill in blank
hardFill all three blanks to create a filtered dictionary of products with quantity above 10.
dbt
filtered = { [1]: [2] for [1] in inventory if inventory[[1]] [3] 10 } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' in filter
Mismatching key and loop variable names
✗ Incorrect
Use item as key, inventory as value, and filter where inventory is greater than 10.