Last active
September 4, 2015 13:00
-
-
Save aguimaraes/1f4edfdeb9b0a133238f 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 fancy_name, (select name from cities where id = persons.addr_city_id) as city, addr_uf, | |
| (select count(*) from ctes where owner_id = persons.id and created_at >= '2015-06-01 00:00:00') as ctes, | |
| (select count(*) from incomes where owner_id = persons.id and created_at >= '2015-06-01 00:00:00') as incomes | |
| from persons | |
| where owner_id is null | |
| and ((select count(*) from ctes where owner_id = persons.id and created_at >= '2015-06-01 00:00:00') > 0 | |
| or (select count(*) from incomes where owner_id = persons.id and created_at >= '2015-06-01 00:00:00') > 0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment