SQL Practice Logo

SQLPractice Online

Scenario SQL Question

Find Product Component Hierarchy (Bill of Materials)

Build mastery in Self Joins Hierarchical with this scenario-based SQL challenge and live execution support.

Problem Statement

Write a recursive CTE to display the complete bill of materials hierarchy for product_id 1 (Bicycle). Show each component and sub-component with their quantities. Return product_id, product_name, component_id, component_name, quantity, and level.

Relevant Tables

bill_of_materials

SQL Concepts Used in This Scenario

Strengthen your understanding with these targeted learning topics: