Created
September 1, 2016 21:22
-
-
Save mcdee/f46612adaff3a9409eb4fae293937aff to your computer and use it in GitHub Desktop.
This file contains 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 lab_name, COUNT(*) | |
FROM ( | |
SELECT (record ->> 'scientist_id')::BIGINT AS scientist_id | |
FROM measurements | |
WHERE | |
record @> '{"value_1":0}' AND | |
record @> '{"value_2":0}' AND | |
record @> '{"value_3":0}' | |
) m | |
JOIN scientist_labs AS s | |
ON (m.scientist_id = s.scientist_id) | |
GROUP BY lab_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment