Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 13. Subqueries > Using Subqueries in the FROM Clause

13.6. Using Subqueries in the FROM Clause

Subqueries may be used in the FROM clause of a SELECT statement. In the following query, we find the average of the sums of the population of each continent:

mysql> SELECT AVG(cont_sum)
    -> FROM (SELECT Continent, SUM(Population) AS cont_sum
    ->       FROM Country
    ->       GROUP BY Continent
    ->      ) AS t;
+----------------+
| AVG(cont_sum)  |
+----------------+
| 868392778.5714 |
+----------------+


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial