+1
I tried your statement on our system...very nice.
-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Dan Bale
Sent: Thursday, January 4, 2024 2:37 PM
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxxxxxxxx>
Cc: VERNON HAMBERG Owner <vhamberg@xxxxxxxxxxxxxxx>
Subject: RE: SQL list column from multiple records on one line
LISTAGG! Thanks for that reminder!
Implementer change management users may recognize the IMENLB table as the Environment Library List file.
SELECT LBENNM, LISTAGG( trim(LBNAME), ', ') WITHIN GROUP (ORDER BY LBSQNO) AS Library_List FROM MKSIM/IMENLB GROUP BY LBENNM ;
SELECT 'CHGLIBL (' || trim( LISTAGG( trim(LBNAME), ' ') WITHIN GROUP (ORDER BY LBSQNO) ) || ')' AS CHGLIBLcmd FROM MKSIM/IMENLB where LBENNM = '<some environment>'
GROUP BY LBENNM
;
Works like a charm! Thanks Vern!
- Dan
-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of VERNON HAMBERG Owner via MIDRANGE-L
Sent: Thursday, January 4, 2024 2:16 PM
To: midrange-l@xxxxxxxxxxxxxxxxxx
Cc: VERNON HAMBERG Owner <vhamberg@xxxxxxxxxxxxxxx>; midrange-l@xxxxxxxxxxxxxxxxxx
Subject: Re: SQL list column from multiple records on one line
I think LISTAGG can get the same result, and it involves a grouping, here it'd be grouped on the car manufacturer, I think. Much easier than this approach. I'll have to ask Kent about it.
Cheers
Vern
*** CONFIDENTIALITY NOTICE: The information contained in this communication may be confidential, and is intended only for the use of the recipients named above. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication, or any of its contents, is strictly prohibited. If you have received this communication in error, please return it to the sender immediately and delete the original message and any copy of it from your computer system. If you have any questions concerning this message, please contact the sender. ***
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: 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
Before posting, please take a moment to review the archives at
https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.
As an Amazon Associate we earn from qualifying purchases.