Lessons › SQL › Chapter 1: Reading data
SQL lesson
Column aliases with AS
A column alias gives a column a temporary, human-friendly name in your results without changing anything in the actual database.
Try this lesson free →Example
Renaming Retail Columns with AS
SELECT product_id AS product_code,
product_name AS item_name,
category AS product_category,
price AS selling_price
FROM productsStep by step
- Rename one column with AS. The original column name stays in the table; only the result label changes.
SELECT product_id AS product_code FROM products; - Alias a second column the same way - column name, then AS, then the new label.
SELECT product_id AS product_code, product_name AS item_name FROM products; - You can alias as many columns as you like. Each pair follows the same pattern.
SELECT product_id AS product_code, product_name AS item_name, category AS product_category FROM products;
Practice
1. Write a query on the orders table to show the revenue column renamed as total_revenue.
SELECT revenue AS total_revenue FROM orders2. Write a query on the products table to show the product_id column renamed as item_code.
SELECT product_id AS item_code FROM products3. Write a query on the customers table to show the phone column renamed as contact_number.
SELECT phone AS contact_number FROM customers4. Write a query on the inventory table to show the stock_count column renamed as units_available.
SELECT stock_count AS units_available FROM inventory5. Write a query on the returns table to show the return_date column renamed as refund_date.
SELECT return_date AS refund_date FROM returnsLearn it by doing. This lesson is a short hands-on level on Bampaa: see it work, then build and write it yourself, with instant feedback.
Try this lesson free →