Last active
August 1, 2017 20:07
-
-
Save josephcc/d0a96800b24af6dbb98d29dee0953507 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 | |
string_agg(token, ' ') as ngram, | |
count(*) as count, | |
review_id, | |
MIN(start) AS start, MAX("end") AS end, | |
CASE | |
WHEN token = 'guy' THEN | |
index + 1 | |
WHEN token = 'stand' THEN | |
unnest(ARRAY[index, index+1]) | |
ELSE | |
index | |
END AS _index | |
FROM | |
index | |
WHERE | |
city = 'Tempe' AND | |
token IN ('guy', 'stand', 'behind') | |
GROUP BY _index, review_id | |
HAVING string_agg(token, ' ') in ('guy stand', 'stand behind') | |
ORDER BY count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment