Project - Analyzing Unicorn Companies
  • AI Chat
  • Code
  • Report
  • Beta
    Spinner

    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

    ColumnDescription
    company_idA unique ID for the company.
    date_joinedThe date that the company became a unicorn.
    year_foundedThe year that the company was founded.

    funding

    ColumnDescription
    company_idA unique ID for the company.
    valuationCompany value in US dollars.
    fundingThe amount of funding raised in US dollars.
    select_investorsA list of key investors in the company.

    industries

    ColumnDescription
    company_idA unique ID for the company.
    industryThe industry that the company operates in.

    companies

    ColumnDescription
    company_idA unique ID for the company.
    companyThe name of the company.
    cityThe city where the company is headquartered.
    countryThe country where the company is headquartered.
    continentThe continent where the company is headquartered.
    Unknown integration
    DataFrameavailable as
    df
    variable
    SELECT * FROM companies
    This query is taking long to finish...Consider adding a LIMIT clause or switching to Query mode to preview the result.
    Unknown integration
    DataFrameavailable as
    df
    variable
    WITH top_industries AS (
      SELECT i.industry, COUNT(*) as num_new_unicorns
      FROM dates d
      JOIN industries i ON d.company_id = i.company_id
      WHERE d.date_joined BETWEEN '2019-01-01' AND '2021-12-31'
      GROUP BY i.industry
      ORDER BY num_new_unicorns DESC
      LIMIT 3
    ),
    yearly_rankings AS (
      SELECT i.industry, EXTRACT(YEAR FROM d.date_joined) as year, COUNT(*) as num_unicorns, ROUND(AVG(f.valuation)/1000000000, 2) as average_valuation_billions
      FROM dates d
      JOIN funding f ON d.company_id = f.company_id
      JOIN industries i ON d.company_id = i.company_id
      JOIN top_industries t ON i.industry = t.industry
      WHERE EXTRACT(YEAR FROM d.date_joined) IN (2019, 2020, 2021)
      GROUP BY EXTRACT(YEAR FROM d.date_joined), i.industry
      ORDER BY i.industry, year DESC
    )
    SELECT *
    FROM yearly_rankings;
    
    /* This query uses two CTEs: top_industries and yearly_rankings.
    
    The first CTE top_industries identifies the top-performing industries based on the number of new unicorns created over the last three years, using the same query as before.
    
    The second CTE yearly_rankings then joins the top_industries CTE with the dates, funding, and industries tables, using the EXTRACT function to filter for companies that became unicorns in 2019, 2020, or 2021. It then calculates the number of unicorns in each industry in each year, as well as the average valuation per industry per year, converted to billions of dollars and rounded to two decimal places. Finally, the results are ordered by industry and year in descending order.
    
    The main query then selects all columns from the unicorn_trends CTE, which provides the industry, the year, the number of companies in these industries that became unicorns each year in 2019, 2020, and 2021, along with the average valuation per industry per year, for the top-performing industries. */
    
    This query is taking long to finish...Consider adding a LIMIT clause or switching to Query mode to preview the result.