English subtitles

← Count all the Species - Intro to Relational Databases

Get Embed Code
4 Languages

Showing Revision 3 created 05/25/2016 by Udacity Robot.

  1. So here is the question again.
  2. We're trying to write a query that
    returns all the species in the zoo,
  3. along with their populations.
  4. And here is one possible answer.
  5. Select count of star as num,
    species from animals.
  6. Group by species.
  7. Order by num descending,
    or desc for short.
  8. And here's what's going
    on in that query.
  9. Count star as num, and species
    are the columns that we want to return.
  10. Animals is the table that
    we're going to select from.
  11. We're aggregating by species and
    aggregation is the count.
  12. And then we're ordering,
    by that count column num descending.
  13. By answering this quiz,
  14. we've put together the count
    aggregation, grouping and ordering.
  15. The query for this exercise did not
    require the where clause at all,
  16. because we didn't want to exclude
    any rows from the census.