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 :

Requête nomenclature multi-niveaux avec cumul quantité [12c]


Sujet :

SQL Oracle

  1. #1
    Candidat au Club
    Homme Profil pro
    Administrateur ERP
    Inscrit en
    Avril 2022
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire (Rhône Alpes)

    Informations professionnelles :
    Activité : Administrateur ERP

    Informations forums :
    Inscription : Avril 2022
    Messages : 2
    Points : 4
    Points
    4
    Par défaut Requête nomenclature multi-niveaux avec cumul quantité
    Bonjour,

    Je travail sur une requête (base ORACLE 12C) qui traite les nomenclatures multi-niveaux d'un article parent avec un CONNECT BY PRIOR, mon problème est le cumul des quantités par niveau.

    Avec la ligne SYS_CONNECT_BY_PATH(LIKQTY,'*') as QTETOTAL, j'obtiens dans le champ QTETOTAL avec par exemple la valeur : *1*2*1*4*1

    je souhaiterais obtenir dans un nouveau champ le résultat de la multiplication *1*2*1*4*1 soit 1x2x1x4x1 = 8

    J'ai essayé avec un mélange de SUBSTR et LENGTH :
    SUBSTR(SUBSTR(SYS_CONNECT_BY_PATH(LIKQTY,'*'),2,LENGTH(SYS_CONNECT_BY_PATH(LIKQTY,'*'))),3,LENGTH(SUBSTR(SYS_CONNECT_BY_PATH(LIKQTY,'*'),2,LENGTH(SYS_CONNECT_BY_PATH(LIKQTY,'*'))))) ...

    Afin de pouvoir récupérer la valeur après chaque * et ensuite faire la multiplication mais au bout d'un moment je me perds, et comme je peux aller jusqu'à 6 niveaux la formule est très longue.

    Est ce qu'il existe une méthode plus simple pour arriver à transformer la valeur par exemple *1*2*1*4*1 en 1x2x1x4x1 = 8 ??

    Attention, cet exemple est simple, dans mes valeurs je peux avoir des nombres à virgule et/ou avec plusieurs chiffres, voir jeux de valeurs ci-dessous.

    Ma requête qui extrait la nomenclature multi niveau :

    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
     
    LECT LEVEL as niveau
    , BOMSEQ
    , ITMREF
    , CPNITMREF
    , LIKQTY
    , CONNECT_BY_ROOT ITMREF as artniv0
    , SYS_CONNECT_BY_PATH (CPNITMREF,'/') as CHEMIN
    , SYS_CONNECT_BY_PATH(LIKQTY,'*') as QTETOTAL
    FROM BOMD bd
    START WITH ITMREF = '11-010'
    and BOMALT=1
    and bd.bomalt=1
    and bd.BOMALTTYP=2
    and bd.CPNTYP<>7
    CONNECT BY PRIOR CPNITMREF =ITMREF
    and BOMALT=1
    and bd.bomalt=1
    and bd.BOMALTTYP=2
    and bd.CPNTYP<>7
    Exemple de jeux de données que j'obtiens avec la requête pour l'article parent 11-010 :

    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
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
     
    create table data
    ( NIVEAU   number
    , BOMSEQ number
    , ITMREF char(15)
    , CPNITMREF char(15)
    , LIKQTY number
    , ARTNIV0 char(15)
    , CHEMIN char(100)
    , QTETOTAL char(80)
    );
     
    insert into data (NIVEAU, BOMSEQ, ITMREF , CPNITMREF, LIKQTY, ARTNIV0, CHEMIN, QTETOTAL)
    select 1, 10,' 11-010', '01-00-0001', 1, '11-010', '/01-00-0001', '*1' from dual union all
    select 2, 5,' 01-00-0001', '02-V-1012', 4, '11-010', '/01-00-0001/02-V-1012', '*1*4' from dual union all
    select 2, 10,' 01-00-0001', '03-01000', 4, '11-010', '/01-00-0001/03-01000', '*1*4' from dual union all
    select 2, 55,' 01-00-0001', '01-M-0007', 1, '11-010', '/01-00-0001/01-M-0007', '*1*1' from dual union all
    select 2, 20,' 01-00-0001', '01-M-0025', 4, '11-010', '/01-00-0001/01-M-0025', '*1*4' from dual union all
    select 2, 25,' 01-00-0001', '01-M-0055', 1, '11-010', '/01-00-0001/01-M-0055', '*1*1' from dual union all
    select 2, 30,' 01-00-0001', '01-M-0056', 2, '11-010', '/01-00-0001/01-M-0056', '*1*2' from dual union all
    select 2, 35,' 01-00-0001', '01-M-0057', 2, '11-010', '/01-00-0001/01-M-0057', '*1*2' from dual union all
    select 2, 40,' 01-00-0001', '01-M-0058', 2, '11-010', '/01-00-0001/01-M-0058', '*1*2' from dual union all
    select 2, 45,' 01-00-0001', '01-M-0092', 2, '11-010', '/01-00-0001/01-M-0092', '*1*2' from dual union all
    select 2, 50,' 01-00-0001', '01-M-0093', 2, '11-010', '/01-00-0001/01-M-0093', '*1*2' from dual union all
    select 1, 5,' 11-010', '01-00-9002', 1, '11-010', '/01-00-9002', '*1' from dual union all
    select 2, 90,' 01-00-9002', '02-V-4001', 1, '11-010', '/01-00-9002/02-V-4001', '*1*1' from dual union all
    select 2, 75,' 01-00-9002', '04-V-0004', 6, '11-010', '/01-00-9002/04-V-0004', '*1*6' from dual union all
    select 2, 5,' 01-00-9002', '01-00-0010', 12, '11-010', '/01-00-9002/01-00-0010', '*1*12' from dual union all
    select 3, 95,' 01-00-0010', '02-V-1003', 7, '11-010', '/01-00-9002/01-00-0010/02-V-1003', '*1*12*7' from dual union all
    select 3, 100,' 01-00-0010', '02-V-1006', 2, '11-010', '/01-00-9002/01-00-0010/02-V-1006', '*1*12*2' from dual union all
    select 3, 105,' 01-00-0010', '03-01300', 2, '11-010', '/01-00-9002/01-00-0010/03-01300', '*1*12*2' from dual union all
    select 3, 110,' 01-00-0010', '03-01600', 2, '11-010', '/01-00-9002/01-00-0010/03-01600', '*1*12*2' from dual union all
    select 3, 115,' 01-00-0010', '03-03900', 1, '11-010', '/01-00-9002/01-00-0010/03-03900', '*1*12*1' from dual union all
    select 3, 45,' 01-00-0010', '01-00-0011', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0011', '*1*12*1' from dual union all
    select 4, 5,' 01-00-0011', '02-M-0014', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0011/02-M-0014', '*1*12*1*1' from dual union all
    select 4, 10,' 01-00-0011', '02-M-0015', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0011/02-M-0015', '*1*12*1*1' from dual union all
    select 4, 40,' 01-00-0011', '02-V-1003', 5, '11-010', '/01-00-9002/01-00-0010/01-00-0011/02-V-1003', '*1*12*1*5' from dual union all
    select 4, 90,' 01-00-0011', '02-V-1006', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0011/02-V-1006', '*1*12*1*1' from dual union all
    select 4, 15,' 01-00-0011', '03-00500', 3, '11-010', '/01-00-9002/01-00-0010/01-00-0011/03-00500', '*1*12*1*3' from dual union all
    select 4, 125,' 01-00-0011', '03-01300', 2, '11-010', '/01-00-9002/01-00-0010/01-00-0011/03-01300', '*1*12*1*2' from dual union all
    select 4, 20,' 01-00-0011', '03-01600', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0011/03-01600', '*1*12*1*1' from dual union all
    select 4, 25,' 01-00-0011', '03-01700', 4, '11-010', '/01-00-9002/01-00-0010/01-00-0011/03-01700', '*1*12*1*4' from dual union all
    select 4, 120,' 01-00-0011', '03-03900', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0011/03-03900', '*1*12*1*1' from dual union all
    select 4, 60,' 01-00-0011', '01-00-0003', 2, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-00-0003', '*1*12*1*2' from dual union all
    select 5, 5,' 01-00-0003', '01-M-0015', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-00-0003/01-M-0015', '*1*12*1*2*1' from dual union all
    select 5, 10,' 01-00-0003', '01-M-0019', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-00-0003/01-M-0019', '*1*12*1*2*1' from dual union all
    select 4, 65,' 01-00-0011', '01-00-0006', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-00-0006', '*1*12*1*1' from dual union all
    select 5, 5,' 01-00-0006', '01-M-0048', 8, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-00-0006/01-M-0048', '*1*12*1*1*8' from dual union all
    select 5, 10,' 01-00-0006', '01-M-0049', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-00-0006/01-M-0049', '*1*12*1*1*1' from dual union all
    select 4, 70,' 01-00-0011', '01-00-0007', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-00-0007', '*1*12*1*1' from dual union all
    select 5, 5,' 01-00-0007', '01-M-0048', 12, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-00-0007/01-M-0048', '*1*12*1*1*12' from dual union all
    select 5, 10,' 01-00-0007', '01-M-0049', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-00-0007/01-M-0049', '*1*12*1*1*1' from dual union all
    select 4, 30,' 01-00-0011', '01-00-0008', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-00-0008', '*1*12*1*1' from dual union all
    select 5, 5,' 01-00-0008', '04-M-0017', 2, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-00-0008/04-M-0017', '*1*12*1*1*2' from dual union all
    select 5, 10,' 01-00-0008', '01-M-0038', 2, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-00-0008/01-M-0038', '*1*12*1*1*2' from dual union all
    select 5, 15,' 01-00-0008', '01-M-0044', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-00-0008/01-M-0044', '*1*12*1*1*1' from dual union all
    select 5, 20,' 01-00-0008', '01-M-0045', 8, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-00-0008/01-M-0045', '*1*12*1*1*8' from dual union all
    select 5, 30,' 01-00-0008', '01-M-0045', 4, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-00-0008/01-M-0045', '*1*12*1*1*4' from dual union all
    select 5, 35,' 01-00-0008', '01-M-0125', 4, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-00-0008/01-M-0125', '*1*12*1*1*4' from dual union all
    select 5, 25,' 01-00-0008', '01-M-0144', 2, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-00-0008/01-M-0144', '*1*12*1*1*2' from dual union all
    select 4, 100,' 01-00-0011', '01-C-0007', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-C-0007', '*1*12*1*1' from dual union all
    select 4, 75,' 01-00-0011', '01-E-0015', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-E-0015', '*1*12*1*1' from dual union all
    select 4, 35,' 01-00-0011', '01-M-0032', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-M-0032', '*1*12*1*1' from dual union all
    select 4, 45,' 01-00-0011', '01-M-0034', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-M-0034', '*1*12*1*1' from dual union all
    select 4, 50,' 01-00-0011', '01-M-0042', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-M-0042', '*1*12*1*1' from dual union all
    select 4, 55,' 01-00-0011', '01-M-0076', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-M-0076', '*1*12*1*1' from dual union all
    select 4, 85,' 01-00-0011', '01-M-0080', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-M-0080', '*1*12*1*1' from dual union all
    select 4, 80,' 01-00-0011', '01-M-0091', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-M-0091', '*1*12*1*1' from dual union all
    select 4, 130,' 01-00-0011', '01-M-0126', 2, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-M-0126', '*1*12*1*2' from dual union all
    select 4, 135,' 01-00-0011', '01-M-0140', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-M-0140', '*1*12*1*1' from dual union all
    select 4, 110,' 01-00-0011', '01-V-0003', 2, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-V-0003', '*1*12*1*2' from dual union all
    select 4, 105,' 01-00-0011', '01-V-0004', 2, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-V-0004', '*1*12*1*2' from dual union all
    select 4, 95,' 01-00-0011', '01-V-0005', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-V-0005', '*1*12*1*1' from dual union all
    select 4, 115,' 01-00-0011', '01-V-0006', 2, '11-010', '/01-00-9002/01-00-0010/01-00-0011/01-V-0006', '*1*12*1*2' from dual union all
    select 3, 5,' 01-00-0010', '01-00-0023', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0023', '*1*12*1' from dual union all
    select 4, 65,' 01-00-0023', '02-V-1003', 5, '11-010', '/01-00-9002/01-00-0010/01-00-0023/02-V-1003', '*1*12*1*5' from dual union all
    select 4, 55,' 01-00-0023', '03-01300', 4, '11-010', '/01-00-9002/01-00-0010/01-00-0023/03-01300', '*1*12*1*4' from dual union all
    select 4, 60,' 01-00-0023', '03-01600', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0023/03-01600', '*1*12*1*1' from dual union all
    select 4, 50,' 01-00-0023', '03-03900', 2, '11-010', '/01-00-9002/01-00-0010/01-00-0023/03-03900', '*1*12*1*2' from dual union all
    select 4, 10,' 01-00-0023', '01-00-0002', 2, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-00-0002', '*1*12*1*2' from dual union all
    select 5, 15,' 01-00-0002', '03-01500', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-00-0002/03-01500', '*1*12*1*2*1' from dual union all
    select 5, 5,' 01-00-0002', '01-M-0031', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-00-0002/01-M-0031', '*1*12*1*2*1' from dual union all
    select 5, 10,' 01-00-0002', '01-M-0067', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-00-0002/01-M-0067', '*1*12*1*2*1' from dual union all
    select 4, 20,' 01-00-0023', '01-00-0004', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-00-0004', '*1*12*1*1' from dual union all
    select 5, 20,' 01-00-0004', '03-01300', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-00-0004/03-01300', '*1*12*1*1*1' from dual union all
    select 5, 10,' 01-00-0004', '01-M-0039', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-00-0004/01-M-0039', '*1*12*1*1*1' from dual union all
    select 5, 5,' 01-00-0004', '01-M-0040', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-00-0004/01-M-0040', '*1*12*1*1*1' from dual union all
    select 5, 15,' 01-00-0004', '01-M-0047', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-00-0004/01-M-0047', '*1*12*1*1*1' from dual union all
    select 4, 25,' 01-00-0023', '01-00-0005', 0.08, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-00-0005', '*1*12*1*.08' from dual union all
    select 5, 20,' 01-00-0005', '03-01300', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-00-0005/03-01300', '*1*12*1*.08*1' from dual union all
    select 5, 10,' 01-00-0005', '01-M-0039', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-00-0005/01-M-0039', '*1*12*1*.08*1' from dual union all
    select 5, 5,' 01-00-0005', '01-M-0041', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-00-0005/01-M-0041', '*1*12*1*.08*1' from dual union all
    select 5, 15,' 01-00-0005', '01-M-0047', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-00-0005/01-M-0047', '*1*12*1*.08*1' from dual union all
    select 4, 35,' 01-00-0023', '01-00-0009', 25, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-00-0009', '*1*12*1*25' from dual union all
    select 5, 5,' 01-00-0009', '01-M-0043', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-00-0009/01-M-0043', '*1*12*1*25*1' from dual union all
    select 5, 10,' 01-00-0009', '01-M-0045', 2, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-00-0009/01-M-0045', '*1*12*1*25*2' from dual union all
    select 5, 15,' 01-00-0009', '01-M-0125', 4, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-00-0009/01-M-0125', '*1*12*1*25*4' from dual union all
    select 4, 15,' 01-00-0023', '01-F-0002', 2, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-F-0002', '*1*12*1*2' from dual union all
    select 5, 5,' 01-F-0002', '01-00-0003', 0.5, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-F-0002/01-00-0003', '*1*12*1*2*.5' from dual union all
    select 6, 5,' 01-00-0003', '01-M-0015', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-F-0002/01-00-0003/01-M-0015', '*1*12*1*2*.5*1' from dual union all
    select 6, 10,' 01-00-0003', '01-M-0019', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-F-0002/01-00-0003/01-M-0019', '*1*12*1*2*.5*1' from dual union all
    select 5, 10,' 01-F-0002', '01-M-0037', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-F-0002/01-M-0037', '*1*12*1*2*1' from dual union all
    select 5, 15,' 01-F-0002', '01-V-0001', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-F-0002/01-V-0001', '*1*12*1*2*1' from dual union all
    select 4, 5,' 01-00-0023', '01-F-0003', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-F-0003', '*1*12*1*1' from dual union all
    select 5, 20,' 01-F-0003', '02-M-0021', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-F-0003/02-M-0021', '*1*12*1*1*1' from dual union all
    select 5, 5,' 01-F-0003', '01-M-0035', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-F-0003/01-M-0035', '*1*12*1*1*1' from dual union all
    select 5, 10,' 01-F-0003', '01-M-0036', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-F-0003/01-M-0036', '*1*12*1*1*1' from dual union all
    select 5, 15,' 01-F-0003', '01-M-0046', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-F-0003/01-M-0046', '*1*12*1*1*1' from dual union all
    select 4, 70,' 01-00-0023', '01-M-0033', 1, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-M-0033', '*1*12*1*1' from dual union all
    select 4, 30,' 01-00-0023', '01-M-0050', 2, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-M-0050', '*1*12*1*2' from dual union all
    select 4, 45,' 01-00-0023', '01-V-0001', 2, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-V-0001', '*1*12*1*2' from dual union all
    select 4, 40,' 01-00-0023', '01-V-0004', 14, '11-010', '/01-00-9002/01-00-0010/01-00-0023/01-V-0004', '*1*12*1*14' from dual union all
    select 3, 50,' 01-00-0010', '01-M-0012', 1, '11-010', '/01-00-9002/01-00-0010/01-M-0012', '*1*12*1' from dual union all
    select 3, 120,' 01-00-0010', '01-M-0081', 1, '11-010', '/01-00-9002/01-00-0010/01-M-0081', '*1*12*1' from dual union all
    select 3, 125,' 01-00-0010', '01-M-0090', 1, '11-010', '/01-00-9002/01-00-0010/01-M-0090', '*1*12*1' from dual union all
    select 3, 130,' 01-00-0010', '01-M-0145', 1, '11-010', '/01-00-9002/01-00-0010/01-M-0145', '*1*12*1' from dual union all
    select 2, 50,' 01-00-9002', '01-00-0013', 0.025, '11-010', '/01-00-9002/01-00-0013', '*1*.025' from dual union all
    select 3, 5,' 01-00-0013', '01-E-0008', 1, '11-010', '/01-00-9002/01-00-0013/01-E-0008', '*1*.025*1' from dual union all
    select 3, 10,' 01-00-0013', '01-M-0005', 1, '11-010', '/01-00-9002/01-00-0013/01-M-0005', '*1*.025*1' from dual union all
    select 3, 15,' 01-00-0013', '01-V-0010', 2, '11-010', '/01-00-9002/01-00-0013/01-V-0010', '*1*.025*2' from dual union all
    select 2, 10,' 01-00-9002', '01-00-0014', 1, '11-010', '/01-00-9002/01-00-0014', '*1*1' from dual union all
    select 3, 5,' 01-00-0014', '01-E-0001', 1, '11-010', '/01-00-9002/01-00-0014/01-E-0001', '*1*1*1' from dual union all
    select 3, 10,' 01-00-0014', '01-M-0111', 0.1, '11-010', '/01-00-9002/01-00-0014/01-M-0111', '*1*1*.1' from dual union all
    select 3, 15,' 01-00-0014', '01-M-0111', 0.1, '11-010', '/01-00-9002/01-00-0014/01-M-0111', '*1*1*.1' from dual union all
    select 3, 20,' 01-00-0014', '01-M-0111', 0.1, '11-010', '/01-00-9002/01-00-0014/01-M-0111', '*1*1*.1' from dual union all
    select 3, 25,' 01-00-0014', '01-M-0111', 0.1, '11-010', '/01-00-9002/01-00-0014/01-M-0111', '*1*1*.1' from dual union all
    select 3, 30,' 01-00-0014', '01-M-0111', 0.08, '11-010', '/01-00-9002/01-00-0014/01-M-0111', '*1*1*.08' from dual union all
    select 3, 35,' 01-00-0014', '01-M-0111', 0.08, '11-010', '/01-00-9002/01-00-0014/01-M-0111', '*1*1*.08' from dual union all
    select 3, 40,' 01-00-0014', '01-M-0111', 0.08, '11-010', '/01-00-9002/01-00-0014/01-M-0111', '*1*1*.08' from dual union all
    select 3, 45,' 01-00-0014', '01-M-0111', 0.08, '11-010', '/01-00-9002/01-00-0014/01-M-0111', '*1*1*.08' from dual union all
    select 2, 15,' 01-00-9002', '01-C-0006', 1, '11-010', '/01-00-9002/01-C-0006', '*1*1' from dual union all
    select 2, 25,' 01-00-9002', '01-C-0009', 1, '11-010', '/01-00-9002/01-C-0009', '*1*1' from dual union all
    select 2, 30,' 01-00-9002', '01-C-0010', 1, '11-010', '/01-00-9002/01-C-0010', '*1*1' from dual union all
    select 2, 35,' 01-00-9002', '01-C-0011', 2, '11-010', '/01-00-9002/01-C-0011', '*1*2' from dual union all
    select 2, 40,' 01-00-9002', '01-C-0013', 1, '11-010', '/01-00-9002/01-C-0013', '*1*1' from dual union all
    select 2, 45,' 01-00-9002', '01-C-0014', 1, '11-010', '/01-00-9002/01-C-0014', '*1*1' from dual union all
    select 2, 55,' 01-00-9002', '01-E-0009', 1, '11-010', '/01-00-9002/01-E-0009', '*1*1' from dual union all
    select 2, 60,' 01-00-9002', '01-M-0053', 2, '11-010', '/01-00-9002/01-M-0053', '*1*2' from dual union all
    select 2, 65,' 01-00-9002', '01-M-0054', 1, '11-010', '/01-00-9002/01-M-0054', '*1*1' from dual union all
    select 2, 70,' 01-00-9002', '01-M-0064', 1, '11-010', '/01-00-9002/01-M-0064', '*1*1' from dual union all
    select 2, 80,' 01-00-9002', '01-V-0011', 4, '11-010', '/01-00-9002/01-V-0011', '*1*4' from dual union all
    select 1, 15,' 11-010', '01-00-9100', 1, '11-010', '/01-00-9100', '*1' from dual union all
    select 2, 5,' 01-00-9100', '01-C-0004', 1, '11-010', '/01-00-9100/01-C-0004', '*1*1' from dual union all
    select 2, 10,' 01-00-9100', '01-C-0005', 1, '11-010', '/01-00-9100/01-C-0005', '*1*1' from dual union all
    select 2, 15,' 01-00-9100', '01-C-0012', 1, '11-010', '/01-00-9100/01-C-0012', '*1*1' from dual union all
    select 2, 20,' 01-00-9100', '01-C-0015', 1, '11-010', '/01-00-9100/01-C-0015', '*1*1' from dual union all
    select 2, 25,' 01-00-9100', '01-E-0007', 1, '11-010', '/01-00-9100/01-E-0007', '*1*1' from dual union all
    select 2, 30,' 01-00-9100', '01-E-0010', 1, '11-010', '/01-00-9100/01-E-0010', '*1*1' from dual union all
    select 2, 30,' 01-00-9100', '01-E-0012', 1, '11-010', '/01-00-9100/01-E-0012', '*1*1' from dual union all
    select 2, 65,' 01-00-9100', '01-F-0014', 1, '11-010', '/01-00-9100/01-F-0014', '*1*1' from dual union all
    select 2, 25,' 01-00-9100', '01-M-0062', 4, '11-010', '/01-00-9100/01-M-0062', '*1*4' from dual union all
    select 2, 30,' 01-00-9100', '01-M-0063', 1, '11-010', '/01-00-9100/01-M-0063', '*1*1' from dual union all
    select 2, 60,' 01-00-9100', '01-M-0095', 1, '11-010', '/01-00-9100/01-M-0095', '*1*1' from dual union all
    select 2, 35,' 01-00-9100', '01-M-0110', 0.07, '11-010', '/01-00-9100/01-M-0110', '*1*.07' from dual union all
    select 2, 40,' 01-00-9100', '01-M-0112', 4, '11-010', '/01-00-9100/01-M-0112', '*1*4' from dual union all
    select 2, 40,' 01-00-9100', '01-V-0008', 4, '11-010', '/01-00-9100/01-V-0008', '*1*4' from dual union all
    select 2, 45,' 01-00-9100', '01-V-0009', 10, '11-010', '/01-00-9100/01-V-0009', '*1*10' from dual union all
    select 2, 50,' 01-00-9100', '01-V-0012', 4, '11-010', '/01-00-9100/01-V-0012', '*1*4' from dual union all
    select 1, 20,' 11-010', '01-E-0006', 1, '11-010', '/01-E-0006', '*1' from dual union all
    select 1, 25,' 11-010', '01-E-0011', 1, '11-010', '/01-E-0011', '*1' from dual union all
    select 1, 30,' 11-010', '01-X-0002', 1, '11-010', '/01-X-0002', '*1' from dual union all
    select 1, 35,' 11-010', '01-X-0003', 1, '11-010', '/01-X-0003', '*1' from dual;
    Merci pour votre aide.

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

    Informations forums :
    Inscription : Août 2008
    Messages : 2 947
    Points : 5 846
    Points
    5 846
    Par défaut
    Toute sorte d'approche dans ce fil de discussion pour réaliser un produit cummulé :

    Perso j'aime bien la solution de mnitu avec le user defined aggregate (mais nécessite le droit de le créer).

    Pour reprendre votre logique, on peut évaluer la multiplication avec xmlquery (cf dernier post)

  3. #3
    Candidat au Club
    Homme Profil pro
    Administrateur ERP
    Inscrit en
    Avril 2022
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire (Rhône Alpes)

    Informations professionnelles :
    Activité : Administrateur ERP

    Informations forums :
    Inscription : Avril 2022
    Messages : 2
    Points : 4
    Points
    4
    Par défaut
    Bonjour skuatamad,

    Merci pour votre réponse, j'ai utilisé xmlquery et cela fonctionne très bien.

    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
     
    LECT LEVEL as niveau
    , BOMSEQ
    , ITMREF
    , CPNITMREF
    , LIKQTY
    , CONNECT_BY_ROOT ITMREF as ARTNIV0
    , SYS_CONNECT_BY_PATH (CPNITMREF,'/') as CHEMIN
    , SYS_CONNECT_BY_PATH(LIKQTY,'*') as QTETOTAL
    , xmlquery(SUBSTR(SYS_CONNECT_BY_PATH(LIKQTY_0,'*'),2) returning content).getNumberVal() as CUMUL
    FROM BOMD bd
    START WITH ITMREF = '11-010'
    and BOMALT=1
    and bd.bomalt=1
    and bd.BOMALTTYP=2
    and bd.CPNTYP<>7
    CONNECT BY PRIOR CPNITMREF =ITMREF
    and BOMALT=1
    and bd.bomalt=1
    and bd.BOMALTTYP=2
    and bd.CPNTYP<>7

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

Discussions similaires

  1. Réponses: 12
    Dernier message: 22/04/2019, 12h37
  2. Réponses: 1
    Dernier message: 22/12/2017, 16h57
  3. Requête sql multi-source avec jointure en pur VBA dans excel
    Par guidav dans le forum Général VBA
    Réponses: 1
    Dernier message: 21/09/2013, 20h33
  4. sql requête sur deux tables avec cumul..
    Par Chris'S dans le forum Langage SQL
    Réponses: 3
    Dernier message: 12/01/2010, 23h23
  5. requête recherche multi table avec table "lien"
    Par wulfram dans le forum Requêtes et SQL.
    Réponses: 6
    Dernier message: 10/01/2008, 09h40

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