Hi Matt,
I'm glad it works for you.
>Thanks very much - that looks just the ticket.
>
>>You have to pad them from the left to the same length to make comparable. Assuming that reference cannot have leading spaces and max len of it is 30 characters
>>
>>
>>SELECT
>> LTRIM(MAX(RIGHT(REPLICATE(' ',30) + RTRIM(ref),30))) As MaxRef
>>...
>>
>>
>>>
>>>AAAA is greater than ZZZ because it has more characters in it.
>>>
>>>My client sees it as being similar to 1111 being bigger than 999.
>>>
--sb--