I am pretty new to SQL. I assume this is fairly simple, but I haven't been able to find a straightforward answer online.
I am writing a simple SQL query to group database records by an enum column, and display the count of each value. It works fine, but the output is displaying the enum integer, where I want it to display the string key of that enum value.
Here is an example of the SQL query:
SELECT COUNT(a.sound) as "Sound Count", a.sound
FROM animals a
GROUP BY a.sound
Here is the enum definition:
enum sound: {
bark: 0,
meow: 1,
moo: 2
}
And here is the output of the query:
Sound Count Sound
2 0
4 1
3 2
Whereas I really want:
Sound Count Sound
2 bark
4 meow
3 moo