Baselight

WITH yearly_counts AS (
  SELECT 
    EXTRACT(YEAR FROM date_joined) AS "year",
    country,
    COUNT(*) AS "count"
  FROM 
    @kaggle.rajkumarpandey02_complete_list_of_unicorn_companies.unicorn
  GROUP BY 
    EXTRACT(YEAR FROM date_joined), country
)
SELECT 
  "year",
  SUM("count") AS total_per_year,
  SUM(CASE WHEN country = 'China' THEN "count" ELSE 0 END) AS china_count,
  SUM(CASE WHEN country = 'United States' THEN "count" ELSE 0 END) AS us_count,
  SUM(CASE WHEN country IN (
    'Germany', 'France', 'United Kingdom', 'Italy', 'Spain', 'Netherlands', 
    'Switzerland', 'Sweden', 'Belgium', 'Ireland', 'Finland', 'Norway', 
    'Denmark', 'Poland', 'Austria', 'Portugal', 'Greece', 'Czech Republic',
    'Hungary', 'Romania', 'Luxembourg', 'Ukraine', 'Estonia', 'Latvia', 
    'Lithuania', 'Croatia', 'Slovakia', 'Slovenia', 'Bulgaria', 'Iceland',
    'Malta', 'Cyprus', 'Liechtenstein', 'Monaco') THEN "count" ELSE 0 END) AS europe_count
FROM 
  yearly_counts
GROUP BY 
  "year"
ORDER BY 
  "year"
yeartotal_per_yearchina_countus_counteurope_count
20112011
20124030
20133030
201412170
20153419121
2016211234
20174218116
201897373811
2019102234418
2020106116611
20215274431064
2022251814743

Share link

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