Skip to content

Instantly share code, notes, and snippets.

@oeon
Created February 4, 2025 14:16
Show Gist options
  • Save oeon/616d5f502ac6a422dc94ab86807617a9 to your computer and use it in GitHub Desktop.
Save oeon/616d5f502ac6a422dc94ab86807617a9 to your computer and use it in GitHub Desktop.
Fulcrum choice values from forms table element, data_name
WITH RECURSIVE nested_elements AS (
SELECT jsonb_array_elements(elements::jsonb) AS element
FROM forms
WHERE name = 'Structure Brushing 2025'
UNION ALL
SELECT jsonb_array_elements(element->'elements')
FROM nested_elements
WHERE element ? 'elements'
)
SELECT
element->>'choices' AS choices
FROM
nested_elements
WHERE
element->>'data_name' = 'environmental_survey_type_visit_1';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment