Skip to content

3.3 — Column Calculations

What You'll Learn

  • How to add calculated columns in your SQL queries
  • Basic arithmetic and expressions
  • Excel formulas vs. SQL expressions

From Excel to SQL: Calculated Columns

In Excel, you add a new column with a formula (e.g., =Amount*1.2). In SQL, you add expressions in your SELECT statement.

SQL:

sql
SELECT Product, Amount, Amount * 1.1 AS Amount_With_Tax
FROM sales;
  • Amount * 1.1 calculates a new value.
  • AS Amount_With_Tax gives the new column a name (alias).

Using Functions

SQL has built-in functions, just like Excel.

Example:

sql
SELECT Product, UPPER(Product) AS Product_Upper
FROM sales;
  • UPPER() converts text to uppercase.
  • ROUND() rounds numbers.
sql
SELECT Amount, Amount * 0.2 AS Tax, Amount * 1.2 AS Total
FROM sales;

Key Points

  • Add calculations directly in your SELECT statement.
  • Use AS to name your calculated columns.
  • SQL supports many functions for text, numbers, and dates.

Next Steps

Next, you’ll learn how to manipulate text—just like using Excel’s text functions.