Sektion 2. Kapitel 3
single
Challenge: Product Category Tree Expansion
Stryg for at vise menuen
Opgave
Swipe to start coding
Create a recursive CTE to list all subcategories under the "Electronics" category in the product_categories table, displaying each category's depth in the hierarchy.
- Use a recursive CTE to traverse the product category hierarchy starting from the "Electronics" category.
- For each category, include its
category_id,category_name,parent_category_id, and the hierarchydepth. - The root category ("Electronics") should have a depth of 1.
- Each direct child should have a depth of 2, their children a depth of 3, and so on.
- Only include categories that are descendants of "Electronics" (including "Electronics" itself).
Løsning
Var alt klart?
Tak for dine kommentarer!
Sektion 2. Kapitel 3
single
Spørg AI
Spørg AI
Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat