I've created a view to query on but does not seem to be working properly. Code:
CREATE VIEW SpeciesTypes AS
SELECT species.Name, count(animal.animalID) as number_of_animals
FROM zoo.species, zoo.animal
WHERE species.speciesID = animal.speciesID
GROUP by Name
This code shows each species name and the number of animals within each species. However, i am trying to write a query in finding out which species has the most number of animals including the species name.
The query that i used was:
SELECT name, max(number_of_animals)
FROM speciestypes;
This showed me correct highest number of animals but the species name does not change.. does anyone know how to fix this? Thanks!