Aggregate functions Flashcards
Use the SUM() function to get the total duration of all films.
TABLE: films
Field; duration
Get the average duration of all films.
TABLE: films
Field; duration
Get the duration of the shortest film.
TABLE: films
Field; duration
Get the duration of the longest film
TABLE: films
Field; duration
Use the SUM() function to get the total amount grossed by all films.
TABLE: films
Field; gross
Get the average amount grossed by all films.
TABLE: films
Field; gross
Get the amount grossed by the worst performing film.
TABLE: films
Field; gross
Get the amount grossed by the best performing film.
TABLE; films
Field; gross
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
Get the average amount grossed by all films whose titles start with the letter ‘A’.
TABLE; films
Field; gross, title
Get the amount grossed by the worst performing film in 1994.
TABLE; films
FIELD; gross, release_year
Get the amount grossed by the best performing film between 2000 and 2012, inclusive.
TABLE; films
FIELD; gross, release_year
what is (4/3) in sql
- 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)
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
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