Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Challenge: Product Category Tree Expansion | Recursive CTEs and Hierarchical Data
Practice
Projects
Quizzes & Challenges
Quizzen
Challenges
/
Mastering Common Table Expressions (CTEs) in SQL
Sectie 2. Hoofdstuk 3
single

single

bookChallenge: Product Category Tree Expansion

Veeg om het menu te tonen

Taak

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 hierarchy depth.
  • 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).

Oplossing

Switch to desktopSchakel over naar desktop voor praktijkervaringGa verder vanaf waar je bent met een van de onderstaande opties
Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 2. Hoofdstuk 3
single

single

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

some-alt