Advertisement
cianoid

Untitled

Aug 13th, 2023
1,523
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. with funds as (
  2.     select
  3.         extract(month from fr.funded_at) mon,
  4.         count(distinct i.fund_id) fund_count
  5.     from funding_round fr
  6.     left join investment i on i.funding_round_id = fr.id
  7.     left join fund f on f.id = i.fund_id
  8.     where
  9.         extract(year from fr.funded_at) between 2010 and 2013 and
  10.         f.country_code = 'USA'
  11.     group by extract(month from fr.funded_at)
  12. ),
  13. sells as (
  14.     select
  15.         extract(month from acquired_at) mon,
  16.         count(distinct acquired_company_id) company_count,
  17.         sum(price_amount) sum_price_amount
  18.     from acquisition a
  19.     group by extract(month from a.acquired_at)
  20. )
  21.  
  22. select
  23.     f.mon,
  24.     f.fund_count,
  25.     sells.company_count,
  26.     sells.sum_price_amount
  27. from funds f
  28. join sells on sells.mon = f.mon
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement