SELECT picks the columns you want and FROM picks the table. The * sign means all columns.
We chose two columns instead of all of them. Open in SQL Lab
Aliases with AS
AS renames a column in the result only. Open in SQL Lab
Arithmetic
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.
List the columns separated by commas after SELECT.
Exercise 2 — Show each product's name and its price after a 10% increase; name the column new_price, rounded to 2 decimals.
Use ROUND(price * 1.1, 2).
- 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.