Recall & Review
beginner
What is a column alias in SQL?
A column alias is a temporary name given to a column in the result set of a query to make the output easier to read or understand.
Click to reveal answer
beginner
How do you assign a column alias in a SELECT statement?
You use the AS keyword followed by the alias name after the column name, like: SELECT column_name AS alias_name FROM table;
Click to reveal answer
intermediate
Can you use column aliases without the AS keyword?
Yes, in many SQL databases including MySQL, you can write the alias directly after the column name with a space, like: SELECT column_name alias_name FROM table;
Click to reveal answer
beginner
Why use column aliases in SQL queries?
Column aliases make output easier to read, especially when columns have complex names or expressions. They also help when combining columns or using functions.
Click to reveal answer
intermediate
Give an example of a column alias with a calculation.
Example: SELECT price, quantity, price * quantity AS total_cost FROM sales; This shows total_cost as the alias for the calculation.
Click to reveal answer
Which keyword is commonly used to assign a column alias in SQL?
✗ Incorrect
The AS keyword is used to assign a column alias in SQL, for example: SELECT column_name AS alias_name.
What will this query return? SELECT price * quantity AS total FROM sales;
✗ Incorrect
The query returns a column named total which contains the result of price multiplied by quantity.
Is this query valid in MySQL? SELECT name full_name FROM users;
✗ Incorrect
MySQL allows column aliases without the AS keyword, so this query is valid.
Why might you use a column alias in a query?
✗ Incorrect
Column aliases only change the name shown in the query result, making it easier to read.
Which of these is a correct way to alias a column?
✗ Incorrect
Both 'AS' keyword and direct alias without AS are valid ways to assign column aliases in MySQL.
Explain what a column alias is and how to use it in a SQL SELECT query.
Think about giving a temporary name to a column in your query output.
You got /3 concepts.
Describe why column aliases are helpful when working with SQL queries.
Consider how query results look to someone reading them.
You got /3 concepts.