Ravindra BagaleCourses & study guides Track your progress

3. SELECT Basics: Read Rows Without Changing Data

3.4 How to Rename a Column in the Result with AS (Alias)

Why. Raw column names are ugly in manager slides.

What. AS gives a column a temporary name in the result (an alias).

How. SELECT amount_inr AS sales_inr FROM orders;

Steps

  1. Pick a money column.
  2. Add AS sales_inr (or sales_usd in other datasets).
  3. Check the header in the result.

Examples

Example 1 · dataset: raja_coffee

SELECT city AS store_city, amount_inr AS sales_inr
FROM orders
LIMIT 4;

Output

store_citysales_inr
Pune840.0
Mumbai720.0
Goa890.0
Pune1050.0

Meaning. Headers now say store_city and sales_inr.

Ravindra Bagale's Tip

Alias names cannot have spaces unless you quote them — prefer sales_inr style.