0
0
SQLquery~20 mins

Column aliases with AS in SQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Column Alias Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
Output of column alias in SELECT
What is the output of this SQL query?

SELECT first_name AS name FROM employees;

Assume the employees table has these rows:
first_name
John
Jane
Bob
SQL
SELECT first_name AS name FROM employees;
A
name
John
Jane
Bob
B
name
first_name
first_name
C
first_name
John
Jane
Bob
DError: Invalid column alias
Attempts:
2 left
💡 Hint
The AS keyword renames the column in the output.
query_result
intermediate
2:00remaining
Multiple column aliases in SELECT
What is the output of this SQL query?

SELECT first_name AS fname, last_name AS lname FROM employees;

Assume employees table rows:
first_name | last_name
Alice      | Smith
Bob        | Brown
SQL
SELECT first_name AS fname, last_name AS lname FROM employees;
A
first_name | last_name
Alice      | Smith
Bob        | Brown
B
fname | lname
Alice | Smith
Bob   | Brown
C
fname | last_name
Alice | Smith
Bob   | Brown
DError: AS keyword used incorrectly
Attempts:
2 left
💡 Hint
Each column alias changes the column header separately.
📝 Syntax
advanced
2:00remaining
Identify the syntax error with AS alias
Which option contains a syntax error when using column alias with AS?
ASELECT salary AS monthly_salary FROM payroll;
BSELECT city AS location FROM addresses;
CSELECT age AS FROM users;
DSELECT price AS cost FROM products;
Attempts:
2 left
💡 Hint
AS must be followed by a valid alias name.
query_result
advanced
2:00remaining
Effect of alias on ORDER BY clause
What is the output order of this query?

SELECT first_name AS name FROM employees ORDER BY name DESC;

Employees table:
first_name
Anna
Zack
Mike
SQL
SELECT first_name AS name FROM employees ORDER BY name DESC;
A
name
Zack
Mike
Anna
B
name
Anna
Mike
Zack
C
first_name
Anna
Zack
Mike
DError: Cannot use alias in ORDER BY
Attempts:
2 left
💡 Hint
Aliases can be used in ORDER BY to sort results.
🧠 Conceptual
expert
2:00remaining
Why use column aliases with AS?
Which is the best reason to use column aliases with AS in SQL queries?
ATo speed up query execution by indexing aliases
BTo change the data type of a column in the table
CTo permanently rename columns in the database schema
DTo rename columns in the output for clarity or formatting
Attempts:
2 left
💡 Hint
Think about what aliases affect: output or schema?