Custom ORDER BY Explanation

@Scott Bailey suggested great idea. But it can be even simpler (you don’t have to create custom function) since PostgreSQL 9.5. Just use array_position function:

ORDER BY array_position(array['Nails','Bolts','Washers','Screws','Staples','Nuts'], s.type)

Leave a Comment