Avsnitt 2. Kapitel 3
single
Challenge: Product Category Tree Expansion
Svep för att visa menyn
Uppgift
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 allt tydligt?
Tack för dina kommentarer!
Avsnitt 2. Kapitel 3
single
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal