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
- Pick a money column.
- Add AS sales_inr (or sales_usd in other datasets).
- 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_city | sales_inr |
|---|---|
| Pune | 840.0 |
| Mumbai | 720.0 |
| Goa | 890.0 |
| Pune | 1050.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.
Ravindra Bagale's Tip – मराठी
Alias मध्ये स्पेस नको (किंवा quotes) — sales_inr स्टाइल चांगली.
Ravindra Bagale's Tip – हिंदी
Alias में स्पेस न रखें (या quotes दें) — sales_inr स्टाइल अच्छी है।