0

I want to convert my parent child table to pivot,below is my query

CREATE  TABLE parent_child 
with recursive cte (id, name, parentid,level) as (
  select     id,
             name,
             parentid,
              0 level
  from       CONFIG_CLASSIFICATION
  where parentid is null
  union all
  select     p.id,
             p.name,
             p.parentid,
            cte.level + 1
  from       CONFIG_CLASSIFICATION p
  inner join cte
          on p.parentid = cte.id
)

My current output enter image description here

My desire output enter image description here

3
  • 1
    Can you provide the sample data and expected result as text instead of images? If you could also add the sample data to a fiddle it will be more likely someone will help you solve. Additionally, why are you doing this - what problem does this solve?
    – user212533
    Commented Oct 18, 2022 at 13:55
  • 1
    It's unclear what you want for the second row of that output.
    – Rick James
    Commented Oct 18, 2022 at 19:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.