SQL Aliases

Temporary names for columns and tables.

✍️ 3 exercises + code challenge in this lesson

An alias gives a column or table a temporary name, making results and queries easier to read.

  • Column: SELECT CustomerName AS Customer
  • Use quotes for names with spaces: AS "Contact Person"
  • Table: FROM Customers AS c, then refer to c.City. Very common in joins.

Key Takeaways: SQL Aliases

Mastering SQL Aliases helps you write clean and reliable SQL code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.

SQL Aliases Code Example

SQL
SELECT CustomerName AS Customer,
       ContactName AS "Contact Person",
       City || ', ' || Country AS Location
FROM Customers AS c
WHERE c.Country = 'Pakistan';
Free sign-in required · Google login available

SQL Aliases Practice Exercises

Check what you learned in “SQL Aliases”.

/ 3 solved
Fill in the blank

Rename the column in the result.

SELECT CustomerName  Customer FROM Customers;
✓ Correct! Not quite. Try again.
Multiple choice

Aliases are…

✓ Correct! Not quite. Try again.
Code challenge

Select ProductName as Item and Price as Cost from Products where ProductID = 1.

Write the code in the live editor. Your answer is checked automatically.

Free sign-in required · Google login available

to save your exercise progress.
Finished this lesson?
Mark it complete to track your progress.

Stuck on something?

Ask the community in the CodesInTech forum.

Need a developer?

Learning on your own is great — and when you need professional help, our team builds custom software, websites and mobile apps for clients worldwide.

Explore Our Services