Baselight
SELECT 
  YEAR(ratings_t."date") AS "year", 
  "household_rating" AS "rating", 
  "cost_of_30_second_ad_usd" AS "cost per 30s (nominal)", 
  COUNT(*) FILTER (WHERE "use_sex") AS "sexy", 
  COUNT(*) FILTER (WHERE "patriotic") AS "patriotic", 
  COUNT(*) FILTER (WHERE "funny") AS "funny",
  COUNT(*) FILTER (WHERE "celebrity") AS "celebrity",
  COUNT(*) FILTER (WHERE "animals") AS "animals"
FROM @kaggle.mattop_super_bowl_television_ratings.super_bowl_ratings ratings_t
LEFT JOIN @kaggle.thedevastator_uncover_america_s_secrets_through_super_bowl_ads.superbowl_ads ads_t
  ON YEAR(ratings_t."date") = ads_t."year"
WHERE "year" BETWEEN 2000 AND 2020
GROUP BY 
  YEAR(ratings_t."date"), 
  "household_rating", 
  "cost_of_30_second_ad_usd"
ORDER BY "year"
yearratingcost per 30s (nominal)sexypatrioticfunnycelebrityanimals
200043.3210000010804
200140.42200000611063
200240.4220000061823
200340.72200000401123
200441.42302200411026
200541.1240000050833
200641.6250000020722
200742.6238536532925
200843.12699963431153
2009423000000231125
2010452800000331123
201146294864920604
201247344275242738
201346.43765130611028
201446.7408486443757
201547.5428312934516
201646.6480000013985
201745.3539987303121
201843.1523537925652
201941.1519991614854
202041.6540000002594

Share link

Anyone who has the link will be able to view this.