Skip to content
SQL Project: Analyzing Unicorn Companies
Did you know that the average return from investing in stocks is 10% per year! But who wants to be average?!
We 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.
We 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. |
Objectives
- Identify the three best-performing industries based on the number of new unicorns created in 2019, 2020, and 2021 combined.
- Find the number of unicorns within these industries and the year they became a unicorn
- Their average valuation converted to billions of dollars and rounded to two decimal places
DataFrameas
df
variable
/* CTE expression using inner join between the industries and dates table to identify the three best performing industries from 2019 to 2021 combined */
WITH top_3_industries AS (SELECT industry AS top_3, COUNT(i.company_id) AS num
FROM industries AS i
INNER JOIN dates AS d
ON i.company_id = d.company_id
WHERE d.date_joined BETWEEN '2019-01-01' AND '2021-12-31'
GROUP BY industry
ORDER BY num DESC
LIMIT 3)
/* Main query joining funding, dates, and industries tables, while using the CTE as subquery to filter for the top 3 industries */
SELECT industry AS Industry, DATE_PART('year', d.date_joined) AS year, COUNT(f.company_id) AS num_unicorns, ROUND(AVG(valuation)/1000000000,2) AS average_valuation_billions
FROM funding AS f
INNER JOIN dates AS d
ON f.company_id = d.company_id
INNER JOIN industries AS i
ON i.company_id = d.company_id
WHERE industry IN (
SELECT top_3
FROM top_3_industries)
GROUP BY industry, year
HAVING DATE_PART('year', d.date_joined) BETWEEN 2019 AND 2021
ORDER BY industry, year DESC;
Conclusions
- Year 2021 was the best year for all the top 3 industries in terms of number of unicorns joining.
- Fintech had the most interesting average valuations for its unicorns companies, with Internet & software services surpassing it slightly only on 2020.
- E-commerce & direct-to consumer almost tripled in number of unicorns joining in 2021, but it was still the industry that experimented the lowest relative increase compared to the other two (Fintech: over 9x, Internet software & services: almost 6x).