Last active
May 11, 2019 08:36
-
-
Save peketamin/848e385206ee0dba45bde07d50c8993e to your computer and use it in GitHub Desktop.
PostgreSQL: JSON query example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- https://www.postgresql.org/docs/9.5/functions-json.html | |
WITH | |
virtual_table AS (SELECT key, value FROM jsonb_each('{"k": {"sub_key": 10}, "k2": {"sub_key": 20}}')), | |
extracted_values AS (SELECT value->'sub_key' AS sub_key FROM virtual_table) | |
SELECT * FROM extracted_values |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment