SQLancer
LESSON 9

SQL (Core) - Queries with expressions

Progress: 0%

Queries with expressions

In addition to fetching raw column values, SQL allows you to perform arithmetic calculations, string transformations, and logical functions directly inside your SELECT expressions.

1. Calculated Columns & Arithmetic Syntax

SELECT title, (domestic_sales + international_sales) / 1000000 AS total_sales_millions FROM movies JOIN boxoffice ON movies.id = boxoffice.movie_id;

Mathematical operators (+, -, *, /, %) can transform numeric columns on the fly.

2. Column Aliases with AS

Using the AS alias_name keyword renames the computed column output header so that result sets remain readable and clear.

🗄️ Schema Explorer SELECTABLE

movies
|

🎯 Exercises Checklist:

1. List all movies and their combined sales in millions of dollars
2. List all movies and their ratings in percent
3. List all movies that were released on even number years
⚡ Practice Console

Data Output

No results. Run query to fetch data.

Current Task Target

5 rows