Remplacer plusieurs UNION par DECODE
Bonjour,
J'ai une question SVP.
Exemple:
Code:
1 2
| select t ,d from t1,t2 where t1.id1=t2.id1 and u like '%10' 'or un'
union select t,d from t1,t2 wheret1.id1=t2.id1 and u like '%11' 'or b' |
Je veux faire le même select utilisant decode pour ' or u' et 'or b'.
Merci.
utliser l'opérateur like dans decode
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| select a,b,c from ab a, ac c,ad d ,
'or unc'
where a.id1=b.id2
and a.id1=c.id1
and a like '%10'
union
select a,b,c from ab a, ac c,ad d ,'or b'
where a.id1=b.id2
and a.id1=c.id1
and a like '%11'
union
select a,b,c from ab a, ac c,ad d ,'or c'
where a.id1=b.id2
and a.id1=c.id1
and a like '%15' |
Je veux refaire ce code pour éliminer les UNION.
Voilà ce que je fais, je veux savoir si c'est correct ou non.
Code:
1 2 3 4 5 6
| select a,b,c from ab a, ac c,ad d ,decode(a,like'%10','or unc',like '%11','or b',like'¨%15','or c')
where a.id1=b.id2
and a.id1=c.id1
and (a like '%10'
or alike '%11'
or a like '%15') |
merci