Created
April 2, 2015 02:04
-
-
Save michelp/183f46239ffc50bfc724 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
| create type search.amounts_by_code as (total integer, purpose_code text); | |
| create or replace function search.amount_by_code(auser text, apath jsonb, args jsonb) | |
| returns setof search.amounts_by_code as $$ | |
| select (sum(amount), purpose_codes)::search.amounts_by_code | |
| from working_transactions | |
| where tran_date > '2012-01-01' and tran_date < '2013-01-01' | |
| and filer ilike '%' || (apath->>0) || '%' | |
| group by purpose_codes order by sum(amount) desc; | |
| $$ language sql; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment