Fantastic, Julian! Thanks for your question, I learned something from it!

Regards
Vern

On 10/25/2024 7:01 AM, Justin Taylor wrote:
This works. Thank you

order by
(case :H <> :H then NumericCol end),
(case :H = :H then CharCol end)




date: Thu, 24 Oct 2024 07:39:51 -0500
from: Vern Hamberg via MIDRANGE-L <midrange-l@xxxxxxxxxxxxxxxxxx>
subject: Re: Implicit cast on ORDER BY

Hi Justin

I just googled for *conditional order by* and got an interesting hit
that might help.

In a CASE, the results must be the same data type, I saw. It wasn't IBM
i, but the rule still holds.

One solution was to use multiple CASE, something like this - I'm just
taking a wild shot here - each CASE can have its own data type -

order by
(case :H <> :H then NumericCol end)
(case :H = :H then CharCol end)

Your USING clause would add a couple values.

Here's a link to the page -
https://stackoverflow.com/questions/15621609/t-sql-conditional-order-by

Regards
Vern



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.