/*
   The queries for Session 11's opening exercise.
*/

-- Compute the average closing price for each stock.

SELECT symbol, AVG(close)
FROM EndOfDayData
GROUP BY symbol;

-- Find the companies whose average closing price is more
-- than five times the average closing price of all stocks.
-- Display the companies' stock symbols in order of their
-- average closing price.

SELECT symbol
FROM (SELECT symbol, AVG(close) AS average
      FROM EndOfDayData GROUP BY symbol)
WHERE average > 8 * (SELECT AVG(close) FROM EndOfDayData);
-- ORDER BY average DESC;

