Hi Kent
what you need to use is
CASE
for example
CASE
WHEN HINGE = 'P' THEN 3
WHEN HEIGHT > 72 THEN 2
WHEN WIDTH > 48 THEN 2
ELSE 1
END AS SORTFIELD
Alan Shore
Programmer/Analyst, Distribution
E:AShore@xxxxxxxxxxx
P:(631) 200-5019
C:(631) 880-8640
"If you're going through Hell, keep going" - Winston Churchill
"Hohlen, Kent"
<Kent.Hohlen@eagl
ewindow.com> To
Sent by: <rpg400-l@xxxxxxxxxxxx>
rpg400-l-bounces@ cc
midrange.com
Subject
How To Create On The Fly Sort Field
07/21/2009 04:26
PM
Please respond to
RPG programming
on the IBM i /
System i
<rpg400-l@midrang
e.com>
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
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at
http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.