IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

SQL Oracle Discussion :

Problème résultat sur deux lignes


Sujet :

SQL Oracle

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Inscrit en
    Juillet 2008
    Messages
    80
    Détails du profil
    Informations forums :
    Inscription : Juillet 2008
    Messages : 80
    Par défaut Problème résultat sur deux lignes
    Bonjour,

    J'ai une vue existante dans oracle. Pour l'instant quand je fais une requete elle me renvoie deux lignes car le dernier select (ME_SUP_REL.RSU_SUP_NUMERO) a deux lignes.
    Je souhaiterai n'afficher qu'une seule ligne en concaténant par exemple le résultat du dernier select dans une seule colonne séparé par un ; par exemple.
    J'ai essayé de remplacer ME_SUP_REL.RSU_SUP_NUMERO par
    MAX(ME_SUP_REL.RSU_SUP_NUMERO )||' ; '||MIN(ME_SUP_REL.RSU_SUP_NUMERO) RSU_SUP_NUMERO mais cela me renvoie toujours deux lignes avec une fois "A50 ; A50" et une fois "P47 ; P47" mais mois je veux une ligne "P47 ; A50".

    Suis-je assez clair?

    Merci pour votre aide.

    Code sql : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    CREATE OR REPLACE VIEW ME_V_SUP_R AS  
    SELECT
    ME_SUPPORT.SUP_IDENT,
    ME_SUPPORT.CO_NUMINSEE,
    ME_SUPPORT.SUP_LTY_IDENT,
    ME_SUP_LTY.SUP_LTY_LIBELLE,
    ME_SUPPORT.SUP_LTE_IDENT,
    ME_SUPPORT.SUP_LPR,
    ME_SUPPORT.SUP_DATE,
    COUNT(ME_SUP_REL.SUP_IDENT) RELATION,
    ME_SUPPORT.LECH_ECHSAISIE,
    ME_PDT.PDT_IDENT,
    ME_SUP_LP.SUP_PEINT_LIBELLE,
    ME_SUP_REL.RSU_SUP_NUMERO
    FROM
    ME_SUPPORT,
    ME_SUP_REL,
    ME_SUP_LTY,
    ME_PDT,
    ME_SUP_LP
    WHERE ME_SUPPORT.SUP_IDENT = ME_PDT.SUP_IDENT(+)
    AND ME_SUPPORT.SUP_IDENT = ME_SUP_REL.SUP_IDENT(+)
    AND ME_SUPPORT.SUP_LTY_IDENT = ME_SUP_LTY.SUP_LTY_IDENT
    AND ME_SUP_LP.SUP_PEINT_IDENT(+) = ME_SUPPORT.SUP_PEINT_IDENT
    GROUP BY
    ME_SUPPORT.SUP_IDENT,
    ME_SUPPORT.CO_NUMINSEE,
    ME_SUPPORT.SUP_LTY_IDENT,
    ME_SUP_LTY.SUP_LTY_LIBELLE,
    ME_SUPPORT.SUP_LTE_IDENT,
    ME_SUPPORT.SUP_LPR,
    ME_SUPPORT.SUP_DATE,
    ME_SUPPORT.LECH_ECHSAISIE,
    ME_PDT.pdt_ident,
    ME_SUP_LP.SUP_PEINT_LIBELLE,
    ME_SUP_REL.RSU_SUP_NUMERO;

  2. #2
    Membre Expert

    Homme Profil pro
    Chef de projet en SSII
    Inscrit en
    Janvier 2004
    Messages
    2 862
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Chef de projet en SSII
    Secteur : Conseil

    Informations forums :
    Inscription : Janvier 2004
    Messages : 2 862
    Par défaut
    Peux-tu donner la requête que tu as exécuté ?

  3. #3
    Membre confirmé
    Inscrit en
    Juillet 2008
    Messages
    80
    Détails du profil
    Informations forums :
    Inscription : Juillet 2008
    Messages : 80
    Par défaut
    Requete:

    select * from me_v_sup_r where sup_ident like 28533;

    Résultat: (simplifié)

    SUP_IDENT CO_NUMINSEE RSU_SUP_NU
    ---------- ----------- ----------
    28533 67374 A50
    28533 67374 P47


    Résultat souhaité:

    SUP_IDENT CO_NUMINSEE RSU_SUP_NU
    ---------- ----------- ----------
    28533 67374 P47;A50

  4. #4
    Membre Expert

    Homme Profil pro
    Chef de projet en SSII
    Inscrit en
    Janvier 2004
    Messages
    2 862
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Chef de projet en SSII
    Secteur : Conseil

    Informations forums :
    Inscription : Janvier 2004
    Messages : 2 862
    Par défaut
    Euh, j'ai peut-être pas les yeux en face des trous, mais je ne vois pas de min et de max, là

  5. #5
    Membre confirmé
    Inscrit en
    Juillet 2008
    Messages
    80
    Détails du profil
    Informations forums :
    Inscription : Juillet 2008
    Messages : 80
    Par défaut
    oui, celui que je t'ai envoyé c'est sans le min et max.

    Ci_dessous le min et le max

    Code sql : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    CREATE OR REPLACE VIEW ME_V_SUP_R AS
    SELECT
    ME_SUPPORT.SUP_IDENT,
    ME_SUPPORT.CO_NUMINSEE,
    ME_SUPPORT.SUP_LTY_IDENT,
    ME_SUP_LTY.SUP_LTY_LIBELLE,
    ME_SUPPORT.SUP_LTE_IDENT,
    ME_SUPPORT.SUP_LPR,
    ME_SUPPORT.SUP_DATE,
    COUNT(ME_SUP_REL.SUP_IDENT) RELATION,
    ME_SUPPORT.LECH_ECHSAISIE,
    ME_PDT.PDT_IDENT,
    ME_SUP_LP.SUP_PEINT_LIBELLE,
    MAX(ME_SUP_REL.RSU_SUP_NUMERO)||';'||MIN(ME_SUP_REL.RSU_SUP_NUMERO) RSU_SUP_NUMERO
    FROM
    ME_SUPPORT,
    ME_SUP_REL,
    ME_SUP_LTY,
    ME_PDT,
    ME_SUP_LP
    WHERE ME_SUPPORT.SUP_IDENT = ME_PDT.SUP_IDENT(+)
    AND ME_SUPPORT.SUP_IDENT = ME_SUP_REL.SUP_IDENT
    AND ME_SUPPORT.SUP_LTY_IDENT = ME_SUP_LTY.SUP_LTY_IDENT
    AND ME_SUP_LP.SUP_PEINT_IDENT(+) = ME_SUPPORT.SUP_PEINT_IDENT
    GROUP BY
    ME_SUPPORT.SUP_IDENT,
    ME_SUPPORT.CO_NUMINSEE,
    ME_SUPPORT.SUP_LTY_IDENT,
    ME_SUP_LTY.SUP_LTY_LIBELLE,
    ME_SUPPORT.SUP_LTE_IDENT,
    ME_SUPPORT.SUP_LPR,
    ME_SUPPORT.SUP_DATE,
    ME_SUPPORT.LECH_ECHSAISIE,
    ME_PDT.pdt_ident,
    ME_SUP_LP.SUP_PEINT_LIBELLE,
    ME_SUP_REL.RSU_SUP_NUMERO;

    résultat:


    SUP_IDENT CO_NUMINSEE RSU_SUP_NU
    ---------- ----------- ----------
    28533 67374 A50;A50
    28533 67374 P47;P47

  6. #6
    Membre Expert

    Homme Profil pro
    Chef de projet en SSII
    Inscrit en
    Janvier 2004
    Messages
    2 862
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Chef de projet en SSII
    Secteur : Conseil

    Informations forums :
    Inscription : Janvier 2004
    Messages : 2 862
    Par défaut
    C'est normal tu fais un group by ME_SUP_REL.RSU_SUP_NUMERO
    => il te renvoie une ligne par ME_SUP_REL.RSU_SUP_NUMERO

    Essaie :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    CREATE OR REPLACE VIEW ME_V_SUP_R AS
    SELECT
    ME_SUPPORT.SUP_IDENT,
    ME_SUPPORT.CO_NUMINSEE,
    ME_SUPPORT.SUP_LTY_IDENT,
    ME_SUP_LTY.SUP_LTY_LIBELLE,
    ME_SUPPORT.SUP_LTE_IDENT,
    ME_SUPPORT.SUP_LPR,
    ME_SUPPORT.SUP_DATE,
    COUNT(ME_SUP_REL.SUP_IDENT) RELATION,
    ME_SUPPORT.LECH_ECHSAISIE,
    ME_PDT.PDT_IDENT,
    ME_SUP_LP.SUP_PEINT_LIBELLE,
    MAX(ME_SUP_REL.RSU_SUP_NUMERO)||';'||MIN(ME_SUP_REL.RSU_SUP_NUMERO) RSU_SUP_NUMERO
    FROM
    ME_SUPPORT,
    ME_SUP_REL,
    ME_SUP_LTY,
    ME_PDT,
    ME_SUP_LP
    WHERE ME_SUPPORT.SUP_IDENT = ME_PDT.SUP_IDENT(+)
    AND ME_SUPPORT.SUP_IDENT = ME_SUP_REL.SUP_IDENT
    AND ME_SUPPORT.SUP_LTY_IDENT = ME_SUP_LTY.SUP_LTY_IDENT
    AND ME_SUP_LP.SUP_PEINT_IDENT(+) = ME_SUPPORT.SUP_PEINT_IDENT
    GROUP BY
    ME_SUPPORT.SUP_IDENT,
    ME_SUPPORT.CO_NUMINSEE,
    ME_SUPPORT.SUP_LTY_IDENT,
    ME_SUP_LTY.SUP_LTY_LIBELLE,
    ME_SUPPORT.SUP_LTE_IDENT,
    ME_SUPPORT.SUP_LPR,
    ME_SUPPORT.SUP_DATE,
    ME_SUPPORT.LECH_ECHSAISIE,
    ME_PDT.pdt_ident,
    ME_SUP_LP.SUP_PEINT_LIBELLE;

  7. #7
    Expert confirmé
    Profil pro
    Inscrit en
    Août 2008
    Messages
    2 954
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2008
    Messages : 2 954
    Par défaut
    Salut,

    C'est normal puisque tu sélectionnes ME_SUP_REL.RSU_SUP_NUMERO, il faut donc qu'il soit dans le group by.
    Mais si tu le mets dans le group by tu auras de nouveau 1 ligne par ME_SUP_REL.RSU_SUP_NUMERO.

    Donc prends le min par exemple.

    Par contre ton decode est mal foutu :
    1) le résultat d'un count est un nombre donc pas besoin de le comparer avec une châne de caractères.
    2) ton decode fait l'inverse de ce que tu voulais faire

    Je te propose donc de remplacer la ligne du decode par :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    DECODE(COUNT(ME_SUP_REL.SUP_IDENT),1,min(ME_SUP_REL.RSU_SUP_NUMERO),(MIN(ME_SUP_REL.RSU_SUP_NUMERO)||' ; '||MAX(ME_SUP_REL.RSU_SUP_NUMERO)))

  8. #8
    Membre confirmé
    Inscrit en
    Juillet 2008
    Messages
    80
    Détails du profil
    Informations forums :
    Inscription : Juillet 2008
    Messages : 80
    Par défaut
    Ca fonctionne comme je le voulais.


    Un grand merci à toi!

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. affichage d'une résultat sur deux lignes
    Par nabil123456 dans le forum Interfaces Graphiques en Java
    Réponses: 1
    Dernier message: 17/04/2015, 11h32
  2. [VB2005]Texte sur deux lignes
    Par Petrolia dans le forum Windows Forms
    Réponses: 1
    Dernier message: 04/06/2006, 14h51
  3. Afficher un résultat sur deux critères du même champ
    Par julien6660 dans le forum Access
    Réponses: 2
    Dernier message: 20/04/2006, 11h30
  4. [JTextArea] Problème ecriture sur plusieurs lignes
    Par Cyborg289 dans le forum Composants
    Réponses: 3
    Dernier message: 23/09/2005, 10h22
  5. [VB.NET] DataGrid : titre des colonnes sur deux lignes
    Par Lahouari dans le forum Windows Forms
    Réponses: 6
    Dernier message: 06/12/2004, 14h44

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo