Aggregate functions Flashcards

1
Q

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

TABLE: films
Field; duration

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

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

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

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

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

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

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

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

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

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

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

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

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

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

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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

TABLE; films
Field; gross, title

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

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

TABLE; films
FIELD; gross, release_year

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

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

TABLE; films
FIELD; gross, release_year

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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