I have the following table named Pokemon that has info about some pokemons.
+------------+-------+--------+--------+--+
| name | type | weight | color | |
+------------+-------+--------+--------+--+
| bulbasaur | grass | 10 | green | |
| squirtle | water | 7 | blue | |
| charmander | fire | 8 | orange | |
| cyndaquil | fire | 4 | black | |
| staryu | water | 12 | orange | |
+------------+-------+--------+--------+--+
I would like to group this table by color and select the name of each pokemon belonging to each color group.
Namely I want 4 groups :
- green
- blue
- orange
- black
and the names of each pokemon in each group:
- bulbasaur
- squirtle
- charmander,staryu
- cyndaquil
I have tried using the GROUP BY clause in SQL like so:
SELECT name
FROM POKEMON
GROUP BY color
but that does not work since the GROUP BY clause insists that the column attribute in SELECT must either be involved in the GROUP BY or have an aggregation function act on it.
Since it is my third day coding in SQL I have not found a solution to this problem yet.
Thank you in advance for your time trying to help.