Aerospace Equipment Labels
Beginner Mode

Scenario

You work in the aerospace industry and have two tables: one with equipment records and another with company details.

Task

Write a Snowflake SQL query that:

  1. Joins {{ ref("equipment") }} with {{ ref("companies") }} on equipment.company_id = companies.id
  2. Renames equipment.name to equipment_name, equipment.type to equipment_type, equipment.status to equipment_status, and companies.name to company_name
  3. Derives a status_label column using the rules below
  4. Returns seven columns: id, equipment_name, equipment_type, equipment_status, company_name, country, status_label

Status label rules:

status country status_label
active USA Domestic Active
active not USA Foreign Active
not active any Inactive

Schema

equipment

Column Type Description
id String Unique equipment identifier
name String Equipment name
type String Equipment category (Rocket, Satellite, etc.)
status String Current operational status
company_id String Foreign key to companies table

companies

Column Type Description
id String Unique company identifier
name String Company name
country String Country where the company is headquartered

Example

equipment:

id name type status company_id
E1 Titan V Rocket active C1
E2 Horizon Satellite active C2
E3 Comet X Probe inactive C1
E4 Nebula Telescope active C3
E5 Pulsar Lander retired C2

companies:

id name country
C1 AstroTech USA
C2 StellarWorks Japan
C3 OrbitCorp USA

Expected Output:

id equipment_name equipment_type equipment_status company_name country status_label
E1 Titan V Rocket active AstroTech USA Domestic Active
E2 Horizon Satellite active StellarWorks Japan Foreign Active
E3 Comet X Probe inactive AstroTech USA Inactive
E4 Nebula Telescope active OrbitCorp USA Domestic Active
E5 Pulsar Lander retired StellarWorks Japan Inactive

Note: E1 and E4 are active with USA companies (Domestic Active). E2 is active with a non-USA company (Foreign Active). E3 and E5 have non-active statuses (Inactive regardless of country).

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 →