SQL LESSON 3 OF 32

Aliases & calculated columns

An expression can calculate a new value without changing stored data. AS gives the result a readable column name. Multiplication uses *. A calculated SELECT is different from an UPDATE.

हिन्दी में समझें

एक्सप्रेशन संग्रहीत डेटा बदले बिना नया मान निकालता है। AS परिणाम को नया नाम देता है। गणना वाला SELECT, UPDATE से अलग है।

अभ्यास: हर उत्पाद का name और price * 1.1 को new_price नाम से दिखाएँ।

Hinglish mein samjhein

Expression stored data ko badle bina nayi value nikalta hai. AS result ka readable naam deta hai. Calculated SELECT data update nahi karta.

Practice: Har product ka name aur price * 1.1 AS new_price dikhao.

A small SQL example

SELECT name, price * 2 AS double_price FROM products;

Examples use the fictional shop database bundled with the SQL playground: customers, products, orders, order_items and employees. The engine is SQLite; other SQL dialects may differ.

Try this example in the SQL playground →

Practise this idea

Show name and price * 1.1 as new_price for every product.

Check answer & explanation
SELECT name, price * 1.1 AS new_price FROM products;

price * 1.1 calculates a ten-percent increase. AS new_price gives that calculated result the requested label; stored prices remain unchanged.

Stuck in the course? Choose Check answer for either the challenge or quiz. Read the explanation and continue to the next lesson at your own pace.

Check your understanding

Does a calculated SELECT change stored prices?

  1. Yes
  2. No
  3. Only for integers
Check the quiz answer

No

An expression can calculate a new value without changing stored data. AS gives the result a readable column name. Multiplication uses *. A calculated SELECT is different from an UPDATE.

References & corrections

Use the official SQLite documentation for full language rules. Read how these lessons are made and checked. Found a mistake? Report it to Excel Keys with this lesson URL and a reproducible example.

FROM LEARNING TO BUSINESS RESULTS

Need a dashboard for your team?

Excel Keys designs custom Excel and HTML dashboards around your own KPIs and Excel files. They run offline in the browser, so your data stays on your computer.