Last active
August 29, 2015 14:19
-
-
Save balkian/f17db63300ee88471ed9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
SELECT count(*) AS C, payload->'retweeted_status'->>'id' AS cat, payload->'retweeted_status'->>'text' AS Tweet FROM messages WHERE jsonb_typeof(payload) = 'object' and payload->>'text' not like '%http%' GROUP BY cat, Tweet ORDER BY C DESC; | |
# Works just fine | |
SELECT count(*) AS C, payload->'retweeted_status'->>'id' AS cat, payload->'retweeted_status'->>'text' AS Tweet, payload->'retweeted_status'->'User'->>'screen_name' AS User FROM messages WHERE jsonb_typeof(payload) = 'object' and payload->>'text' not like '%http%' GROUP BY cat, Tweet, User ORDER BY C DESC; | |
# Doesn't work | |
# ------------ | |
# ERROR: column "messages.payload" must appear in the GROUP BY clause or be used in an aggregate function | |
# LINE 1: ...t, payload->'retweeted_status'->>'text' AS Tweet, payload->'... | |
#Problem: User was the name of a column :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment