# Aggregate functions Flashcards Preview

## SQL > Aggregate functions > Flashcards

Flashcards in Aggregate functions Deck (19)
1
Q

Use the SUM() function to get the total duration of all films.

TABLE: films
Field; duration

A
2
Q

Get the average duration of all films.
TABLE: films
Field; duration

A
3
Q

Get the duration of the shortest film.
TABLE: films
Field; duration

A
4
Q

Get the duration of the longest film
TABLE: films
Field; duration

A
5
Q

Use the SUM() function to get the total amount grossed by all films.
TABLE: films
Field; gross

A
6
Q

Get the average amount grossed by all films.
TABLE: films
Field; gross

A
7
Q

Get the amount grossed by the worst performing film.
TABLE: films
Field; gross

A
8
Q

Get the amount grossed by the best performing film.
TABLE; films
Field; gross

A
9
Q

Use the SUM() function to get the total amount grossed by all films made in the year 2000 or later.

TABLE; films
Fields; gross, release_year

A
10
Q

Get the average amount grossed by all films whose titles start with the letter ‘A’.

TABLE; films
Field; gross, title

A
11
Q

Get the amount grossed by the worst performing film in 1994.

TABLE; films
FIELD; gross, release_year

A
12
Q

Get the amount grossed by the best performing film between 2000 and 2012, inclusive.

TABLE; films
FIELD; gross, release_year

A
13
Q

what is (4/3) in sql

A
1. Carful!!!
because both are stated as integers you will get an integer back
if you want the decimal back you need to do
(3.0/4.0)
14
Q

Get the title and net profit (the amount a film grossed, minus its budget) for all films. Alias the net profit as net_profit.

TABLE; films
FIELD; gross, budget, title

A
15
Q

Get the title and duration in hours for all films. The duration is in minutes, so you’ll need to divide by 60.0 to get the duration in hours. Alias the duration in hours as duration_hours.

TABLE; films
FIELD; duration, title

A
16
Q

Get the average duration in hours for all films, aliased as avg_duration_hours.

TABLE; films
FIELD; duration

A
17
Q

Get the percentage of people who are no longer alive. Alias the result as percentage_dead. Remember to use 100.0 and not 100!

TABLE; people
FIELDS; deathdate

A
18
Q

Get the number of years between the newest film and oldest film. Alias the result as difference.

TABLE; films
FIELDS; release_year

A
19
Q

Get the number of decades the films table covers. Alias the result as number_of_decades. The top half of your fraction should be enclosed in parentheses.

TABLE; films
FIELD; release_year

A