How do I get my code to show the highest of each species?

Asked

Viewed 46 times

3

I’m trying as follows (exercise link: SQL Teaching - GROUP BY)

SELECT * FROM friends_of_pickles GROUP BY Species;

Table:

  • 1 Dave Male Human 180
  • 2 Mary Female Human 160
  • 3 Fry Male cat 30
  • 4 Leela Female cat 25
  • 5 Odie Male dog 40
  • 6 Jumpy Male dog 35
  • 7 Sneakers Male dog 55

1 answer

5


Using the ORDER BY, crescent ASC or decreasing DESC.

SELECT * FROM friends_of_pickles GROUP BY species ORDER BY nome_da_coluna (ASC|DESC);

EDIT1:

Reference W3C: http://www.w3schools.com/sql/sql_orderby.asp

EDIT2:

After I answered I noticed I had a link to the exercise.

The correct exercise would be using only height_cm and Species fields.

SELECT MAX(height_cm), species FROM friends_of_pickles GROUP BY species

Browser other questions tagged

You are not signed in. Login or sign up in order to post.