I have data like this which I need to flatten for each Id with the corresponding key and size with two different columns.
So I was watching the tutorial on snowflake which has this function
select distinct json.key as column_name, 
from raw.public.table_name, 
     lateral flatten(input => table_name) json
I was trying to find something in postgres query
id | json_data
 
1  | {"KEY": "mekq1232314342134434", "size": 0}
2  | {"KEY": "meksaq12323143421344", "size": 2}
3  | {"KEY": "meksaq12323324421344", "size": 3}
So I need two things here first I need a distinct key from these jsonb columns,
2. I need to flatten the jsonb columns
id | kEY | size
1  | mekq1232314342134434 | 0
 
    