|
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<mailto: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
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx<mailto:MIDRANGE-L@xxxxxxxxxxxxxxxxxx>
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx<mailto:MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx>
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxxxxxxxxxx<mailto:support@xxxxxxxxxxxxxxxxxxxx> for any subscription related
questions.
As an Amazon Associate we earn from qualifying purchases.
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.