Skip to content

Instantly share code, notes, and snippets.

@raeno
Forked from stevenharman/select_from_subquery.sql
Created April 11, 2014 11:51
Show Gist options
  • Save raeno/10461784 to your computer and use it in GitHub Desktop.
Save raeno/10461784 to your computer and use it in GitHub Desktop.
select fund_sums.total, fund_products.name
from (
select sum(allocation_amount) total, fund_product_id
from transactions
where transactions.investor_id = 490
group by fund_product_id
) fund_sums
left join fund_products on fund_sums.fund_product_id = fund_products.id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment