Created
October 3, 2018 20:06
-
-
Save cpcloud/120202a0f288324aaa273de74752ca2f to your computer and use it in GitHub Desktop.
Buggy SQL Query
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 *, | |
acq_ipos / num_investments AS acq_rate | |
FROM ( | |
SELECT CASE WHEN i.investor_name IS NULL THEN ‘NO INVESTOR’ | |
ELSE i.investor_name | |
END AS “Investor name”, | |
COUNT(DISTINCT c.permalink) AS num_investments, | |
COUNT(DISTINCT | |
CASE WHEN c.status IN (‘ipo’, ‘acquired’) THEN c.permalink | |
END) AS acq_ipos | |
FROM crunchbase_companies | |
LEFT JOIN crunchbase_investments | |
ON c.permalink = i.company_permalink | |
GROUP BY 1 | |
ORDER BY 2 DESC | |
) t |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment