Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Challenge: Product Category Tree Expansion | Recursive CTEs and Hierarchical Data
Practice
Projects
Quizzes & Challenges
Вікторини
Challenges
/
Mastering Common Table Expressions (CTEs) in SQL
Секція 2. Розділ 3
single

single

bookChallenge: Product Category Tree Expansion

Свайпніть щоб показати меню

Завдання

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

Рішення

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 2. Розділ 3
single

single

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

some-alt