× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Can you try something like...

Select
Field1,
Case when fieldx = 'value1' then 1
When fieldx = 'value2' then 2
Else 3 end as mysort
From library/table
Order by 2

Thanks
George
Sent from my Verizon Wireless BlackBerry

-----Original Message-----
From: "Hohlen, Kent" <Kent.Hohlen@xxxxxxxxxxxxxxx>

Date: Tue, 21 Jul 2009 15:21:28
To: <rpg400-l@xxxxxxxxxxxx>
Subject: How To Create On The Fly Sort Field


Hello,

I'm trying to figure out a way to create a sort field that will have
different values based on the value of different fields in each record
retrieved by a SQL statement in a RPG program. For example, if the
record returned has a "P" in the hinge field, I want this record to have
a sort value of 3. Else if the height is greater then 72, then the sort
value should be a 2. Else if the width is greater then 48, then the
sort value should also be a 2. If none of these conditions are true,
then the sort field should have a value of 1. Then I would like to use
the sort field in the ORDER BY clause.

I'm not having any luck figuring out how to create the condition syntax
and getting the sort field to work.

Any help is greatly appreciated.

Thanks,
Kent


As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.