deniswhite77

19/23

Feb 17th, 2022 (edited)
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. WITH
  2. a AS (SELECT company_id,
  3.             raised_amount
  4.     FROM funding_round
  5.     WHERE EXTRACT(YEAR FROM CAST(funded_at AS date)) BETWEEN '2012' AND '2013'),
  6.  
  7. b AS(SELECT company_id,
  8.     fund_id
  9.     FROM investment),
  10.    
  11. c AS (SELECT id,
  12.              name
  13.      FROM fund),
  14. d AS (SELECT id AS company_id,
  15.          name As name_of_company
  16.      FROM company
  17.      WHERE milestones>6)
  18.      
  19.        
  20. SELECT c.name name_of_found,
  21.     d.name_of_company,
  22.     SUM(a.raised_amount) AS amount
  23.    
  24.  
  25.    
  26. FROM a INNER JOIN b ON (a.company_id = b.company_id)
  27. INNER JOIN c ON (b.fund_id = c.id)
  28. INNER JOIN d ON(a.company_id = d.company_id)
  29. GROUP BY name_of_found,d.name_of_company
Add Comment
Please, Sign In to add comment