Task 9 Queries with expressions Flashcards

1
Q

List all movies and their combined sales in millions of dollars

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

List all movies and their ratings in percent

A

SELECT title, rating * 10 AS rating_percent
FROM movies
JOIN boxoffice
ON movies.id = boxoffice.movie_id;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

List all movies that were released on even number years

A

SELECT title, year
FROM movies
WHERE year % 2 = 0;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

AS

A

The AS keyword in SQL is used to alias columns or tables, allowing you to rename them temporarily for the duration of the query.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

ABS

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly