jeudi 6 août 2015

Custom ordering in Max()

Suppose I have a table 'things' which has a column 'ranking'. There are 5 records with the values First, Second, Third, Fourth and Fifth in the ranking column.

I want to be able to use

select Max(ranking) from things

to return 'Fifth', instead of its default 'Third'.

Also, I would want Fourth to be considered greater than Third, etc. etc.

How can I accomplish this?

SQL Server 2005

Aucun commentaire:

Enregistrer un commentaire