Skip to content
Advertisement

How to get JSONB array index

I’m sure there’s a simple answer to this but I just can’t find it. I need to obtain JSON array elements as rows, but their index is relevant for the subsequent processing. Here’s a [very simplified] example:

I need to get:

I’ve tried:

But the section column is not computed correctly, as shown below:

Advertisement

Answer

You can use with ordinality

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement