I have a column, called parametre
, which contains our parameters:
--option 1 TYP_SPRAC;PRIJEM_CISTY;DOKLAD;PL;MULTI;1;DOKLAD_EDI;DL+FAKT --option 2 TYP_SPRAC;PRIJEM_VRATKA;DOKLAD;PL;MULTI;1;DOKLAD_EDI;FAKT
So i want to get a output FA
or DL
, according to string PRIJEM_CISTY
or PRIJEM_VRATKA
:
--joinning to another table... NVL( (select distinct 'FA' from import_par p JOIN import_doc ON p.partner=partner where p.PARAMETRE like '%PRIJEM_VRATKA%'), (select distinct 'DL' from import_par p JOIN import_doc ON p.partner=partner where p.PARAMETRE like '%PRIJEM_CISTY%') )
It works. But is there any “better” solution for this ? For example, decode()
or RegExp()
?
Advertisement
Answer
You can put the two together to query
select decode(max( case when parametre like '%PRIJEM_VRATKA%' then 2 when parametre like '%PRIJEM_CISTY%' then 1 end), 2, 'FA', 1, 'DL') from import_par;