|
Just for fun:
drop table qtemp/test;
create table qtemp/test (Type *char*(*1*));
*insert* into qtemp/test (Type) values('1') , ('2') , ('3') , ('4') ,
('A');
drop table qtemp/testcol;
create table qtemp/testcol (Valid *char*(*10*) , vCol1 *char*(*10*), vCol2
*char*(*10*), vCol3 *char*(*10*));
*insert* into qtemp/testcol values(' ABC' , ' 111' , ' 222' , ' 333');
SELECT
*TRIM*(
*CONCAT*(
*SUBSTR*(vCol1, *COALESCE*(*TRY_CAST*(Type AS *INTEGER*),
*0*
) + *1*, *1*), *SUBSTR*(
Valid, *COALESCE*(*TRY_CAST*(Type AS *INTEGER*), *0*) +
*1*, *1*))) AS Col1,
*TRIM*(
*CONCAT*(
*SUBSTR*(vCol2, *COALESCE*(*TRY_CAST*(Type AS *INTEGER*),
*0*
) + *1*, *1*), *SUBSTR*(
Valid, *COALESCE*(*TRY_CAST*(Type AS *INTEGER*), *0*) +
*1*, *1*))) AS Col2,
*TRIM*(
*CONCAT*(
*SUBSTR*(vCol3, *COALESCE*(*TRY_CAST*(Type AS *INTEGER*),
*0*
) + *1*, *1*), *SUBSTR*(
Valid, *COALESCE*(*TRY_CAST*(Type AS *INTEGER*), *0*) +
*1*, *1*))) AS Col3
FROM qtemp/test
CROSS JOIN qtemp/testcol;
--
Marco Facchinetti
Mr S.r.l.
Tel. 035 962885
Cel. 393 9620498
Skype: facchinettimarco
Il giorno mar 5 nov 2024 alle ore 16:30 Dave <dfx1@xxxxxxxxxxxxxx> ha
scritto:
Hello,list
Can I merge these statements into 1 CASE statement or do I need to repeat
the conditions as below?
Thanks
CASE
type
WHEN '1' THEN '1A'
WHEN '2' THEN '1B'
ELSE ' '
END col1
CASE
type
WHEN '1' THEN '2A'
WHEN '2' THEN '2B'
ELSE ' '
END col2
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
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.
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.
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.