Last active
August 29, 2015 14:02
-
-
Save mfcabrera/cdaaf372e52c272ad877 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
COPY ( | |
select r.cluster_id, r.token_array from hotel4x.review as r where | |
r.lang = 'en' and r.cluster_id in | |
(SELECT h.cluster_id | |
FROM hotel4x.hotel AS h | |
INNER JOIN ( | |
SELECT s.cluster_id, COUNT(*) AS source_count | |
FROM hotel4x.source AS s | |
GROUP BY s.cluster_id | |
) AS s USING (cluster_id) | |
INNER JOIN ( | |
SELECT r.cluster_id, COUNT(*) AS review_count | |
FROM hotel4x.review AS r | |
WHERE r.source_id != 16 AND r.date >= NOW() - INTERVAL '730 days' | |
GROUP BY r.cluster_id | |
HAVING COUNT(*) >= 5 | |
) AS r USING (cluster_id) | |
where h.trust_score is not NULL | |
) | |
) | |
TO STDOUT | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment