I have a table with multiple records. For example
PERSON, COLOR
John, orange
John, blue
Jack, green
Jack, purple
I know I can get min, max, first records using those operations. Is there a way to get the first value based on an ordered list. For the given example data above I'd like to get the first value in the order {red,orange,yellow,green,blue,indigo,violet}. So the result of the query would be
person, color
John, orange
Jack, green
Is there some syntax similar to this in standard sql or other specific dialects?
select
person,
first(color)
from (
select * from person_color
order by color{'red','orange','yellow','green','blue','indigo','violet'})
;