Created
March 3, 2017 20:36
-
-
Save alexmchale/3172ad02df31b0c0e78fdafcbd511f1e 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(1) FROM ( | |
SELECT s_stats.id | |
FROM s_stats | |
LEFT JOIN s_organizations ON s_stats.organization_id = s_organizations.id | |
WHERE stats_purged_sents IS NULL | |
AND ( | |
( | |
( ( s_organizations.permissions -> 'quota_mode' ) is not distinct from 'no_limit' ) | |
OR | |
( ( s_organizations.permissions -> 'quota_limit' ) is distinct from '1' ) | |
) | |
OR | |
( | |
s_organizations.deleted_at IS NULL | |
) | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment