Второй уровень. Вы считаете агрегаты, группируете данные и соединяете таблицы.
Работаем с таблицами Crunchbase, акциями Apple и футболистами. Описание таблиц: Учебные данные . Нужны знания из уровня Основы .
Решайте сами, без AI. Сначала задание, потом проверка, и только потом решение.
1
N
1
N
1
N
tutorial.crunchbase_acquisitions
company_permalink
text
company_name
text
acquirer_name
text
acquired_at
text
acquired_year
bigint
price_amount
double
price_currency_code
text
… ещё 13 ст.
benn.college_football_teams
division
text
conference
text
school_name
text
roster_url
text
id
int
tutorial.aapl_historical_stock_price
date
date
year
int
month
int
open
double
high
double
low
double
close
double
volume
bigint
id
int
tutorial.crunchbase_companies
permalink
text
name
text
category_code
text
funding_total_usd
bigint
status
text
country_code
text
state_code
text
founded_at
text
founded_year
bigint
… ещё 8 ст.
tutorial.crunchbase_investments
company_permalink
text
company_name
text
investor_permalink
text
investor_name
text
investor_country_code
text
funding_round_type
text
funded_at
text
funded_year
bigint
raised_amount_usd
double
… ещё 11 ст.
tutorial.crunchbase_investments_part1
Компании A–L
Те же столбцы, что у
crunchbase_investments
tutorial.crunchbase_investments_part2
Компании M–Z
Те же столбцы, что у
crunchbase_investments
benn.college_football_players
full_school_name
text
school_name
text
player_name
text
position
text
height
int
weight
int
year
text
hometown
text
state
text
id
int
Как читать схему. Линия — связь для JOIN. Подписи 1 и N показывают, сколько строк с каждой стороны: у одной компании может быть много покупок и инвестиций. Выделенный столбец — ключ соединения. Пунктир — представление (view): часть данных другой таблицы. Таблицы без линий не связаны с остальными. Показаны главные столбцы широких таблиц. Полный список столбцов: Учебные данные .
Агрегатные функции
COUNT
SUM
MIN и MAX
AVG
GROUP BY
HAVING
CASE
DISTINCT
JOIN
INNER JOIN
Внешние соединения (OUTER JOIN)
LEFT JOIN
RIGHT JOIN
Фильтр в WHERE или в ON
FULL OUTER JOIN
UNION
JOIN с операторами сравнения
JOIN по нескольким ключам
Self JOIN