79602653

Date: 2025-05-01 23:24:27
Score: 0.5
Natty:
Report link

To filter for all records with only South codes only:

SELECT product_id, f.*
FROM table AS a
INNER JOIN LATERAL FLATTEN (input => a.location_codes) AS f
WHERE f.Key = 'South'

To filter for the record which has the value of 'south3':

SELECT product_id, f1.value::varchar AS location_code
FROM table AS a
INNER JOIN LATERAL FLATTEN (input => a.location_codes) AS f
INNER JOIN LATERAL FLATTEN (input =>f.value) AS f1
WHERE f.Key = 'South'
    AND f1.value::varchar = 'south3'
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Tyler Moore