Skip to content

Instantly share code, notes, and snippets.

@techgaun
Last active June 10, 2016 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save techgaun/31f8968cc2552a6a68c4d11a5b6676b2 to your computer and use it in GitHub Desktop.
Save techgaun/31f8968cc2552a6a68c4d11a5b6676b2 to your computer and use it in GitHub Desktop.
Postgresql Notes

Get all the keys in jsonb fields

select distinct jsonb_object_keys(sfdata) from accounts;

Get values of given key that's more than 0 in jsonb field

select (sfdata->>'BUILDING_SIZE__C')::float from accounts where (sfdata->>'BUILDING_SIZE__C' = '') is false and cast(sfdata->>'BUILDING_SIZE__C' as float) > 0 limit 5;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment