Task 9 Queries with expressions Flashcards
List all movies and their combined sales in millions of dollars
SELECT title, (domestic_sales + international_sales) / 1000000 AS gross_sales_millions
FROM movies
JOIN boxoffice
ON movies.id = boxoffice.movie_id;
List all movies and their ratings in percent
SELECT title, rating * 10 AS rating_percent
FROM movies
JOIN boxoffice
ON movies.id = boxoffice.movie_id;
List all movies that were released on even number years
SELECT title, year
FROM movies
WHERE year % 2 = 0;
AS
The AS keyword in SQL is used to alias columns or tables, allowing you to rename them temporarily for the duration of the query.
ABS
The ABS function in SQL returns the absolute value of a numeric expression. The absolute value is the non-negative value of a number, regardless of its sign. (-100) = 100