Récuperation de deux categorie dans un case
bonjour,
dans ma requête, je sélectionne un champ en fonction d'un identifiant et j'ai remarqué que pour un numéro, on doit avoir deux valeurs or, il n'y a qu'une seul valeur qui est retourné, voici ma requête :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
SELECT distinct numentreprise as numero,
nvl(
case
when
NVL((select t2.alias from tablecode t2
where t2.valeur=fonction(id,sysdate, 'code1')
and idref=10),' ')='Oui'
or
NVL((select t2.alias from tablecode t2
where t2.valeur=fonction(id,sysdate, 'code2')
and idref=10),' ')='Oui'
then 'organisation 1'
when
NVL((select t2.alias from tablecode t2
where t2.valeur=fonction(id,sysdate, 'code3')
and idref=10),' ')='Oui'
or
NVL((select t2.alias from tablecode t2
where t2.valeur=fonction(id,sysdate, 'code4')
and idref=10),' ')='Oui'
or
NVL((select t2.alias from tablecode t2
where t2.valeur=fonction(id,sysdate, 'code5')
and idref=10),' ')='Oui'
or
NVL((select t2.alias from tablecode t2
where t2.valeur=fonction(id,sysdate, 'code6')
and idref=10),' ')='Oui'
or
NVL((select t2.alias from tablecode t2
where t2.valeur=fonction(id,sysdate, 'code7')
and idref=10),' ')='Oui'
then 'organisation 2'
end,'-') "Organisation"
FROM tablepersonne ta
........................
where ta.numero = 123456 |
pour le numéro 123456, je dois avoir "Organisation1 + Organisation 2 " de retourné, car dans la sous requête :
Code:
1 2 3 4
|
NVL((select t2.alias from tablecode t2
where t2.valeur=fonction(id,sysdate, 'code1')
and idref=10),' ')='Oui' |
retourne oui mais aussi la sous requête :
Code:
1 2 3 4
|
NVL((select t2.alias from tablecode t2
where t2.valeur=fonction(id,sysdate, 'code6')
and idref=10),' ')='Oui' |
retourne bien oui également, mais je ne sais pas comment interpréter cela.
merci pour vos lumières