Bonjour à tous,
J'aimerais pouvoir supprimer les doublons des résultats d'un select. Le problème est que j'effectue un order by sur une colonne que je n'affiche pas, mais dont la valeur est différente pour les valeurs en double (je dois tout de même faire cet order by car j'aimerai afficher mes hosts dans un certain ordre).
Ma requête est la suivante :
Select T_LIST_HOST.ID_HOST, HOST_NAME, OS from T_LIST_HOST, T_LIST_COMPONENT, T_SITE_HOST where T_LIST_HOST.ID_HOST=T_LIST_COMPONENT.ID_HOST and T_LIST_COMPONENT.ID_HOST=T_SITE_HOST.ID_HOST and T_SITE_HOST.ID_SITE=2 ORDER BY COMPONENT_TYPE;
Ce qui me donne (un extrait) :
ID_HOST HOST_NAME OS
10 machine10 SunOS 5.8
9 machine9 SunOS 5.8
8 machine8 SunOS 5.8
7 machine7 SunOS 5.8
36 machine36 Netapp
36 machine36 Netapp
36 machine36 Netapp
36 machine36 Netapp
36 machine36 Netapp
36 machine36 Netapp
36 machine36 Netapp
36 machine36 Netapp
36 machine36 Netapp
37 machine37 Netapp
37 machine37 Netapp
37 machine37 Netapp
37 machine37 Netapp
37 machine37 Netapp
37 machine37 Netapp
2 machine2 AIX 4.3
3 machine3 AIX 4.3
4 machine4 AIX 4.3
4 machine4 AIX 4.3
Si j'affiche le COMPONENT_TYPE, on voit bien que pour le même host, la valeur de COMPONENT_TYPE peut-être différente, même si je n'en veux qu'une seule occurence puisque je n'affiche pas ce dernier (ce qui m'interdit l'utilisation de distinct et unique pour la première requête) :
Select T_LIST_HOST.ID_HOST, HOST_NAME, OS, COMPONENT_TYPE from T_LIST_HOST, T_LIST_COMPONENT, T_SITE_HOST where T_LIST_HOST.ID_HOST=T_LIST_COMPONENT.ID_HOST and T_LIST_COMPONENT.ID_HOST=T_SITE_HOST.ID_HOST and T_SITE_HOST.ID_SITE=2 ORDER BY COMPONENT_TYPE;
ID_HOST HOST_NAME OS COMPONENT_TYPE
10 machine10 SunOS 5.8 3
9 machine9 SunOS 5.8 3
8 machine8 SunOS 5.8 3
7 machine7 SunOS 5.8 3
36 machine36 Netapp 3
36 machine36 Netapp 4
36 machine36 Netapp 4
36 machine36 Netapp 4
36 machine36 Netapp 5
36 machine36 Netapp 6
36 machine36 Netapp 6
36 machine36 Netapp 6
36 machine36 Netapp 7
37 machine37 Netapp 7
37 machine37 Netapp 7
37 machine37 Netapp 7
37 machine37 Netapp 7
37 machine37 Netapp 8
37 machine37 Netapp 8
2 machine2 AIX 4.3 8
3 machine3 AIX 4.3 8
4 machine4 AIX 4.3 8
4 machine4 AIX 4.3 8
Je suis en Oracle 9i du côté server. Si vous avez une idée pour n'afficher qu'un triptique (ID_HOST, HOST_NAME, OS) dans cet ordre, je suis preneur !
Merci d'avance.
Partager