Gomaa Intelligence.Data Hub
عربي

Foundations › SQL › SQL Basics

🔎 SQL Basics

SELECT and FROM: Choosing and Calculating Columns

Lesson 5 / 14· 8 min

SELECT picks the columns you want and FROM picks the table. The * sign means all columns.

▶ Try it yourself

We chose two columns instead of all of them. Open in SQL Lab

Aliases with AS

▶ Try it yourself

AS renames a column in the result only. Open in SQL Lab

Arithmetic

▶ Try it yourself

We calculated profit and margin from two columns. Open in SQL Lab

For advanced readers Formatting and comments

-- is a single-line comment and /* ... */ is multi-line. Put each column on its own line for easy review. Avoid SELECT * in reports and permanent queries because it breaks dependencies when the table changes.

Exercise 1 — Show each product's name and category.

Exercise 2 — Show each product's name and its price after a 10% increase; name the column new_price, rounded to 2 decimals.

Summary
  • SELECT picks columns and FROM picks the table.
  • AS gives an alias.
  • We can calculate on columns with + - * /.

Want an expert to do it for you?

Gomaa Intelligence turns your data into clear reports and decisions. Tell us your problem and we will reply.

Get your data analyzed by an expert ↗