how to replace with default value when querying a JSONB column with a key that is not present in a particular row giving empty result
Use a left join:
select up.id, r.element -&gt;&gt;'subject' as result 
from &quot;UserProfile&quot; up
  left join jsonb_array_elements(up.result) as r(element) on true