How do I display my highest code for each species?

3

I'm trying the following way (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
asked by anonymous 08.09.2015 / 21:57

1 answer

5

Using ORDER BY , increasing ASC or decreasing DESC .

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

EDIT 1 :

W3C Reference: link

EDIT 2 :

After I answered, I noticed that I had an exercise link.

The correct exercise would be using just the height_cm and species fields.

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

    
08.09.2015 / 22:03