Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WITH
- avg AS (
- SELECT
- AVG(funding_total) AS avg_total,
- country_code AS country,
- EXTRACT(YEAR FROM CAST(founded_at AS DATE)) AS years
- FROM
- company
- GROUP BY
- country_code,
- years
- )
- SELECT
- a1.country,
- a1.avg_total AS avg2011,
- a2.avg_total AS avg2012,
- a3.avg_total AS avg2013
- FROM
- avg AS a1
- INNER JOIN avg AS a2 ON a2.country = a1.country
- INNER JOIN avg AS a3 ON a3.country = a1.country
- WHERE
- a1.years = 2011
- AND a2.years = 2012
- AND a3.years = 2013
- ORDER BY
- avg2011 DESC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement