0
0
MySQLquery~10 mins

Column aliases in MySQL - Interactive Code Practice

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

Complete the code to rename the column 'price' as 'cost' in the output.

MySQL
SELECT price [1] cost FROM products;
Drag options to blanks, or click blank then click option'
AAS
BIS
CTO
DWITH
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'IS' or 'TO' instead of 'AS' for aliasing.
Omitting the alias keyword entirely.
2fill in blank
medium

Complete the code to rename the result of the expression 'price * quantity' as 'total_cost'.

MySQL
SELECT price * quantity [1] total_cost FROM sales;
Drag options to blanks, or click blank then click option'
ATO
BIS
CAS
DBY
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'TO' or 'IS' instead of 'AS'.
Not using any alias keyword.
3fill in blank
hard

Fix the error in the code to correctly alias the column 'name' as 'product_name'.

MySQL
SELECT name [1] product_name FROM inventory;
Drag options to blanks, or click blank then click option'
AIS
BAS
CTO
DWITH
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'IS' or 'TO' instead of 'AS'.
Forgetting the semicolon at the end.
4fill in blank
hard

Fill both blanks to rename the column 'salary' as 'monthly_salary' and filter rows where salary is greater than 3000.

MySQL
SELECT salary [1] monthly_salary FROM employees WHERE salary [2] 3000;
Drag options to blanks, or click blank then click option'
AAS
B>
C<
DIS
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'IS' instead of 'AS' for aliasing.
Using '<' instead of '>' in the WHERE clause.
5fill in blank
hard

Fill all three blanks to select the column 'age' aliased as 'user_age', filter users older than 18, and order the results by 'user_age' ascending.

MySQL
SELECT age [1] user_age FROM users WHERE age [2] 18 ORDER BY [3] ASC;
Drag options to blanks, or click blank then click option'
AAS
B>
Cuser_age
Dage
Attempts:
3 left
💡 Hint
Common Mistakes
Ordering by the original column name instead of the alias.
Using '<' instead of '>' in the WHERE clause.