Say you have a table cat_dogs:
no_cats | no_dogs | |
---|---|---|
1 | 10 | 0 |
2 | 5 | 6 |
3 | 1 | 2 |
SELECT max_of(Array[no_cats,no_dogs], Array["cats","dogs"]) AS dominant_animal, *
FROM cat_dogs
the function will return
no_cats | no_dogs | dominant_animal | |
---|---|---|---|
1 | 10 | 0 | cats |
2 | 5 | 6 | dogs |
3 | 1 | 2 | dogs |