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

single

bookChallenge: Product Category Tree Expansion

Swipe um das Menü anzuzeigen

Aufgabe

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).

Lösung

Switch to desktopWechseln Sie zum Desktop, um in der realen Welt zu übenFahren Sie dort fort, wo Sie sind, indem Sie eine der folgenden Optionen verwenden
War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 2. Kapitel 3
single

single

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

some-alt