0
0
SQLquery~5 mins

Column aliases with AS in SQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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 use the AS keyword in SQL?
You use AS to assign a new name (alias) to a column or expression in the SELECT statement, like: SELECT column_name AS alias_name FROM table_name;
Click to reveal answer
beginner
Why would you use a column alias in a query?
To make column names more readable, to rename complex expressions, or to prepare output for reports or user interfaces.
Click to reveal answer
intermediate
Can you use column aliases without the AS keyword?
Yes, in many SQL dialects you can write SELECT column_name alias_name FROM table_name; but using AS improves clarity.
Click to reveal answer
beginner
Example: Write a query to select the column 'price' from 'products' table and rename it to 'Cost'.
SELECT price AS Cost FROM products;
Click to reveal answer
What does the AS keyword do in SQL?
ADeletes a column from a table
BCreates a new table
CAssigns a temporary name to a column or expression
DFilters rows in a query
Which of the following is a correct way to alias a column named 'salary' as 'Income'?
ASELECT salary AS Income FROM employees;
BSELECT salary Income FROM employees;
CSELECT salary = Income FROM employees;
DSELECT salary INTO Income FROM employees;
Is the AS keyword mandatory when creating a column alias?
AOnly mandatory in SELECT * queries
BYes, always mandatory
COnly mandatory for table aliases
DNo, it is optional in many SQL dialects
What will this query return? SELECT price AS Cost FROM products;
AA column named 'Cost' with data from 'price'
BAll columns from products table
CAn error because AS is not allowed
DA column named 'price' with original data
Why might you want to use a column alias?
ATo change the data type of a column
BTo make output easier to read or understand
CTo permanently rename a column in the table
DTo delete a column from the table
Explain what a column alias is and how to use the AS keyword in SQL.
Think about how you rename columns temporarily in query results.
You got /3 concepts.
    Describe why column aliases are useful when writing SQL queries.
    Consider how output looks to users or reports.
    You got /3 concepts.