Bonjour a tous,

J'ai un petit soucis sur une requete :


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
select distinct tc1.toto_id
from temp_corresp tc1, temp_corresp tc2, toto_caracteristique ac, toto a, toto a2
where tc1.code=tc2.code
and a.ID=tc1.toto_ID
and a2.ID=tc2.toto_ID
and a.titi_id=a2.titi_id
and tc1.toto_id != tc2.toto_id
and tc1.INDICE='A' and tc2.INDICE='A'
and ac.CODE=tc1.CODE
and ((a.FONCTION_ID=ac.FCTTOTO) or (ac.FCTTOTO='XXX'))
and ac.IND_DOUBLON=0;
L'idee est qu'il faudrait que si a.FONCTION_ID=ac.FCTTOTO alors ma requete serait

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
select distinct tc1.toto_id
from temp_corresp tc1, temp_corresp tc2, toto_caracteristique ac, toto a, toto a2
where tc1.code=tc2.code
and a.ID=tc1.toto_ID
and a2.ID=tc2.toto_ID
and a.titi_id=a2.titi_id
and tc1.toto_id != tc2.toto_id
and tc1.INDICE='A' and tc2.INDICE='A'
and ac.CODE=tc1.CODE
and a.FONCTION_ID=ac.FCTTOTO
and ac.IND_DOUBLON=0;
sinon

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
select distinct tc1.toto_id
from temp_corresp tc1, temp_corresp tc2, toto_caracteristique ac, toto a, toto a2
where tc1.code=tc2.code
and a.ID=tc1.toto_ID
and a2.ID=tc2.toto_ID
and a.titi_id=a2.titi_id
and tc1.toto_id != tc2.toto_id
and tc1.INDICE='A' and tc2.INDICE='A'
and ac.CODE=tc1.CODE
and ac.FCTTOTO='XXX'
and ac.IND_DOUBLON=0;

J'ai essaye

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
select count (distinct tc1.toto_id)
from temp_corresp tc1, temp_corresp tc2, toto_caracteristique ac, toto a, toto a2
where tc1.code=tc2.code
and a.ID=tc1.toto_ID
and a2.ID=tc2.ADV_ID
and a.titi_id=a2.titi_id
and tc1.toto_id != tc2.toto_id
and tc1.INDICE='A' and tc2.INDICE='A'
and ac.CODE=tc1.CODE
and ac.IND_DOUBLON=0
and decode (ac.FCTTOTO,a.FONCTION_ID,ac.FCTTOTO,'XXX');

mais ca renvoie une erreur.

Si quelqu'un avait une idee ...

Merci d'avance