Skip to content
Advertisement

How to extract different json elements from the same table in SQL query?

I am querying from a table with the following format:

I am trying to get a table that looks like the following:

Note that used to json in sql

Advertisement

Answer

id | attscore | verizonscore
-: | :------- | :-----------
 1 | 300      | 299         
 2 | 200      | null        
 3 | null     | 155         

db<>fiddle here

This works with a fixed number of column quite well, if you have much more of these you need to do something like this

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