Skip to content
Did you know that the average return from investing in stocks is 10% per year! But who wants to be average?!
You have been asked to support an investment firm by analyzing trends in high-growth companies. They are interested in understanding which industries are producing the highest valuations and the rate at which new high-value companies are emerging. Providing them with this information gives them a competitive insight as to industry trends and how they should structure their portfolio looking forward.
You have been given access to their unicorns
database, which contains the following tables:
dates
Column | Description |
---|---|
company_id | A unique ID for the company. |
date_joined | The date that the company became a unicorn. |
year_founded | The year that the company was founded. |
funding
Column | Description |
---|---|
company_id | A unique ID for the company. |
valuation | Company value in US dollars. |
funding | The amount of funding raised in US dollars. |
select_investors | A list of key investors in the company. |
industries
Column | Description |
---|---|
company_id | A unique ID for the company. |
industry | The industry that the company operates in. |
companies
Column | Description |
---|---|
company_id | A unique ID for the company. |
company | The name of the company. |
city | The city where the company is headquartered. |
country | The country where the company is headquartered. |
continent | The continent where the company is headquartered. |
DataFrameavailable as
top3_ind
variable
SELECT
industry,
count(distinct(dates.company_id)) as number_of_n_unicorns
FROM industries
LEFT JOIN dates on industries.company_id = dates.company_id where date_trunc('year',date_joined) in ('01-01-2019','01-01-2020','01-01-2021')
group by 1 order by 2 DESC LIMIT 3
DataFrameavailable as
df
variable
SELECT
industry,
date_trunc('year',date_joined) y,
count(distinct(dates.company_id)) as num_unicorns,
AVG(valuation) AS avg_valuation
FROM industries
LEFT JOIN dates on industries.company_id = dates.company_id
LEFT JOIN funding on industries.company_id = funding.company_id
WHERE
date_trunc('year',date_joined) in ('01-01-2019','01-01-2020','01-01-2021')
AND
industry in('fintech','Internet software & services','E-commerce & direct-to-consumer')
GROUP BY 1,2
DataFrameavailable as
df
variable
WITH raw_table AS
(SELECT
industry,
date_trunc('year',date_joined) y,
count(distinct(dates.company_id)) as num_unicorns,
AVG(valuation) AS avg_valuation
FROM industries
LEFT JOIN dates on industries.company_id = dates.company_id
LEFT JOIN funding on industries.company_id = funding.company_id
WHERE
date_trunc('year',date_joined) in ('01-01-2019','01-01-2020','01-01-2021')
AND
industry in('fintech','Internet software & services','E-commerce & direct-to-consumer')
GROUP BY 1,2)
SELECT
industry,
y,
num_unicorns,
ROUND((avg_valuation/1000),2) average_valuation_billions
FROM raw_table
group by 1,2,3,avg_valuation ORDER BY industry,y,average_valuation_billions DESC