Skip to content

Instantly share code, notes, and snippets.

@vvaezian
Created November 22, 2020 02:47
Show Gist options
  • Save vvaezian/06a042f2b5c05edfa299f9f068e39699 to your computer and use it in GitHub Desktop.
Save vvaezian/06a042f2b5c05edfa299f9f068e39699 to your computer and use it in GitHub Desktop.
select a.id, title_type,
case when title_type in ('movie', 'tvMovie') then 'Movie'
when title_type in ('tvSeries', 'tvMiniSeries') then 'Series'
end as item_type,
original_title, primary_title, start_year, runtime_minutes,
genres, avg_rating, num_votes
into movies_series
from source_basics a join source_ratings b on a.id = b.id
where title_type in ('movie', 'tvMovie', 'tvSeries', 'tvMiniSeries');
select a.parent_id "Series ID", a.id "Episode ID",
a.season_number "Season", a.episode_number "Episode",
b.avg_rating "Rating", b.num_votes "# Votes",
c.original_title, c.primary_title, c.start_year,
c.end_year, c.runtime_minutes, c.genres,
d.original_title episode_original_title,
d.primary_title episode_title, d.start_year "Episode Year"
into episodes
from source_episodes a
join source_ratings b on a.id = b.id
join source_basics d on a.id = d.id
join source_basics c on a.parent_id = c.id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment