Skip to content

Instantly share code, notes, and snippets.

@drob
Last active August 29, 2015 14:09
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 drob/4209925d8d3499e02a04 to your computer and use it in GitHub Desktop.
Save drob/4209925d8d3499e02a04 to your computer and use it in GitHub Desktop.
SELECT
user_id,
1 AS view_homepage,
min(time) AS view_homepage_time
FROM event
WHERE
data->>'type' = 'view_homepage'
GROUP BY user_id
@daemonfire300
Copy link

 data->>'type' = 'view_homepage'

I've never seen this sytnax in Postgresql what does it mean, and where is it in the official docs?

@renzok
Copy link

renzok commented Dec 3, 2014

data is of type json and ->> is an operator which gets a JSON object field as text. Here the object field has name 'type' and its values (casted to text) get compared to 'view_homepage'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment