|
PREPARE is not going to help with the differing field count in the GROUP
BY. The select statement will fail if you select on fields that are not
in the group by, or prefixed by an aggregate function. I hesitate to just
give you the answer in the GROUP BY, because I suspect you may also have
an issue in the SELECT section of your statement so I don't really no how
to fix the GROUP BY code. Chances are, you can make the two GROUP BY
sections much more similar than they currently are.
___________________________________
Darren Strong
Dekko
From: Jack Tucky <jacktucky@xxxxxxxxx>
To: "RPG programming on the IBM i (AS/400 and iSeries)"
<rpg400-l@xxxxxxxxxxxx>
Date: 07/31/2017 12:01 PM
Subject: Re: Sql Case question
Sent by: "RPG400-L" <rpg400-l-bounces@xxxxxxxxxxxx>
Thank you. Can I do a CASE on the group by too? It's looking like it
might be easier to do a PREPARE.
On Mon, Jul 31, 2017 at 10:41 AM, Darren Strong <darren@xxxxxxxxx> wrote:
The case cannot communicate a list to the group by. You need a caseselect
statement for each field that is not common between the two conditions.
Now, I see the size of the list is different between the two conditions.
You'll have to use aggregate functions around those fields, in the
statement, such as max() to prevent errors on invalid fields in theselect
list.LS.MOD,
___________________________________
Darren Strong
Dekko
From: Jack Tucky <jacktucky@xxxxxxxxx>
To: "RPG programming on the IBM i (AS/400 and iSeries)"
<rpg400-l@xxxxxxxxxxxx>
Date: 07/31/2017 09:46 AM
Subject: Sql Case question
Sent by: "RPG400-L" <rpg400-l-bounces@xxxxxxxxxxxx>
I want to use CASE on my order by and group by. This syntax isn't
working.
group by
case when :S1SKU = 'Y' then
LM.TYP, LS.SHP, LS.SEA, LS.STY, LS.CLR, LS.FAB,
LS.MSZ, LS.SIZ, LS.AUX1, LS.AUX2, LS.HST, LS.STS,LS.MOD,
LS.HRE, LS.PST, LS.RID, LS.PLT, LX.BLD, LX.SEC,
LX.SLT, LX.AIS, LX.LVL
ELSE
LM.TYP, LS.SHP, LS.SEA, LS.STY, LS.CLR, LS.FAB,
LS.MSZ, LS.SIZ, LS.AUX1, LS.AUX2, LS.HST, LS.STS,instead
LS.HRE, LS.PST, LS.RID, LS.PLT, LX.BLD, LM.SRT
END
I've seen some examples where you specify "Case" for each example
of else, and also the END needs to be after the first field LM.TYP but--
neither worked form.
Thanks for any help.
Art
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (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.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (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.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD
This is the RPG programming on the IBM i (AS/400 and iSeries) (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.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (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.
Please contact support@xxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD
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.