Problème de ligne en doublon
Résolu
ptisephy
Messages postés
78
Statut
Membre
-
ptisephy Messages postés 78 Statut Membre -
ptisephy Messages postés 78 Statut Membre -
Bonjour,
je suis sous sqldevelopper et je rencontre souvent un problème de doublon, lorsque j'éxécute certaines requêtes.
Ex :
si je fais un simple select avec distinct, qui me retourne identifiant, nom, prenom, age avec 5/6 inner join , j'ai aucun problème il me retourne 10 lignes .
Mais quand je rajoute toutes les autres informations, ex : nomEntreprise, siret, n°rib, iban, tempstravaillé dans l'entreprise, etc....... là j'ai mes 10 lignes mais au total je me retrouve avec par ex 250 lignes car j'ai plein de lignes en double, comment ça se fait ?
merci à vous
je suis sous sqldevelopper et je rencontre souvent un problème de doublon, lorsque j'éxécute certaines requêtes.
Ex :
si je fais un simple select avec distinct, qui me retourne identifiant, nom, prenom, age avec 5/6 inner join , j'ai aucun problème il me retourne 10 lignes .
Mais quand je rajoute toutes les autres informations, ex : nomEntreprise, siret, n°rib, iban, tempstravaillé dans l'entreprise, etc....... là j'ai mes 10 lignes mais au total je me retrouve avec par ex 250 lignes car j'ai plein de lignes en double, comment ça se fait ?
merci à vous
1 réponse
-
Bonjour,
Il faudrait que tu nous montres un peu ta requête et les données de ta base pour qu'on puisse te répondre. Ça peut venir de tes données, des jointures...
Xavier-
voici un morceau de code, légèrement modifié
SELECT distinct td5.idss as matricule, td8.numero_entreprise,td6.annee
from table_dossier_2 t2
inner join table_dossier_1 tdossier on t2.idref_table_dossier_2 = tdossier.tdossier_id
inner join table_personne t4 on tdossier1.tdossier_idgrp=t4.x503_id
inner join table5 td5 on x503_idreftd5=x530_idreftd5
inner join table_anne td6 on tdossier1.tdossier_idd010 = td6.dzx010
inner join table_personne td8 on td8.az503_id=t2.c211_idadh
inner join table_relation t9 on t9.az508_idgrp_1=td8.az503_id
inner join table_conge2 tconso2 on tconso2.xvc230_IDGRP=td8.az503_id
inner join table_conge3 tcon3 on tcon3.xvc240_IDxvc230 = tconso2.xvc230_ID
inner join table_nomi tdna on tdna.dzx120_IDCONTRAT= t9.az508_id
inner join table_anne td6 on td6.dzx010=tdossier1.tdossier__idd010
and t9.az508_idgrp_2=t4.az503_id
and td6.annee= '2016'
là je n'ai que 3 champs donc il me retourne 3 lignes, avec 3 personnes différentes donc là ok.
quand je rajoute ne serait-ce un champs en plus ( le temps travaillé dans l'entreprise par ex) , là j'ai 7 lignes:
identifiant numero entreprise annee temps travaillé
1000000000 123456 2016 1236
1000000000 123456 2016 48
1000000000 123456 2016 752
1000000001 123456 2016 12
1000000001 123456 2016 300
1000000002 123456 2016 1236
1000000003 123456 2016 78
et parmi les doublons il n'y a que :
1000000000 123456 2016 1236
qui soit la ligne que je veux récupérer, n'y a til pas un soucis de jointure ou de condition pas assez restrictive ?
Le fait que j'ai plusieurs autres champs n'arrange pas les choses, je me retrouve avec des doublons par ex :
1000000000 123456 2016 1236 20 lignes avec des valeurs différentes pour certains champs -
bonsoir, je trouve suspect que tu doives mettre "distinct" dans ta requête.
je ferais d'abord cette requête:SELECT td5.idss as matricule, td8.numero_entreprise,td6.annee from table_dossier_2 t2 inner join table_dossier_1 tdossier on t2.idref_table_dossier_2 = tdossier.tdossier_id inner join table_personne t4 on tdossier1.tdossier_idgrp=t4.x503_id inner join table5 td5 on x503_idreftd5=x530_idreftd5 inner join table_anne td6 on tdossier1.tdossier_idd010 = td6.dzx010 inner join table_personne td8 on td8.az503_id=t2.c211_idadh inner join table_relation t9 on t9.az508_idgrp_1=td8.az503_id inner join table_conge2 tconso2 on tconso2.xvc230_IDGRP=td8.az503_id inner join table_conge3 tcon3 on tcon3.xvc240_IDxvc230 = tconso2.xvc230_ID inner join table_nomi tdna on tdna.dzx120_IDCONTRAT= t9.az508_id inner join table_anne td6 on td6.dzx010=tdossier1.tdossier__idd010 and t9.az508_idgrp_2=t4.az503_id and td6.annee= '2016'
je suppose que cela va te donner des doublons. pour déterminer ce qui cause ces doublons, je rajouterais dans le SELECT (avant le FROM) des champs que tu utilises dans tes join, cela devrait te montrer celui qui cause les doublons. -
-
-
-