February 14, 2021

Pivot view of key value table

 select

userid,

max(case when name = 'EMAIL' then val else 0 end) as email,

max(case when name = 'PHONE' then val else 0 end) as phone,

max(case when name = 'DOB' then val else 0 end) as dob

from key_value_table

group by userid

No comments:

Post a Comment