Investment by Industry Sector
Beginner Mode

Scenario

You work at a venture capital firm and have two tables: one with company profiles and another with individual investment records.

Task

Write a Snowflake SQL query that:

  1. Joins {{ ref("companies") }} with {{ ref("investments") }} on company_id
  2. Calculates total_investment as the sum of amount per industry
  3. Groups results by industry
  4. Sorts results by total_investment in descending order

Schema

companies

Column Type Description
company_id Integer Unique company identifier
company_name String Name of the company
industry String Industry sector the company belongs to

investments

Column Type Description
investment_id Integer Unique investment identifier
company_id Integer Reference to the company receiving the investment
amount Float Investment amount in dollars

Example

companies:

company_id company_name industry
1 NovaSoft Technology
2 MedVista Healthcare
3 GreenPeak Clean Energy
4 FinBridge Finance
5 StreamCore Technology

investments:

investment_id company_id amount
1 1 4500000
2 2 2800000
3 3 3200000
4 4 1500000
5 5 2000000

Expected Output:

industry total_investment
Technology 6500000
Clean Energy 3200000
Healthcare 2800000
Finance 1500000

Note: NovaSoft and StreamCore both belong to Technology, so their amounts are summed (4500000 + 2000000 = 6500000). Results are sorted from highest to lowest total investment.

Quick Solution

Code Environment

Sign in or try as guest to run your code.

Sign In

Track

Question Difficulty Company Access
Need more practice in this area? Explore more questions →