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

PL/SQL Oracle Discussion :

Comment ne calculer une donnée qu'une fois


Sujet :

PL/SQL Oracle

  1. #1
    Membre du Club
    Femme Profil pro
    recette et qualification
    Inscrit en
    Février 2012
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : recette et qualification
    Secteur : Transports

    Informations forums :
    Inscription : Février 2012
    Messages : 6
    Par défaut Comment ne calculer une donnée qu'une fois
    Bonjour à tous,

    Voilà mon problème,
    J'ai une sous requête qui me ramène le tps_nb_cmde via un appel à une procédure qui fait tout un calcul.
    Dans cette procédure j'utilise un tableau.

    Ensuite je cherche à récupérer le maximum de ce tps_nb_cmde en fonction du pporte_code donc j'utilise :

    MAX(tps_nb_cmde) keep(dense_rank LAST ORDER BY tps_nb_cmde) over(PARTITION BY pporte_code) max_tps_nb_cmde

    Cela ne fonctionne pas ça me renvoie toujours 0.

    J'ai l'impression qu'il y a une incompatibilité entre le dense_rank et le fait d'utiliser un tableau. En effet, cette même ligne fonction avec un autre champ récupéré toujours via une procédure dans un autre package mais sans l'utilisation d'un tableau cette fois-ci.

    Si vous avez une idée je suis preneuse.

    Merci d'avance.
    Astrid

  2. #2
    Membre du Club
    Femme Profil pro
    recette et qualification
    Inscrit en
    Février 2012
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : recette et qualification
    Secteur : Transports

    Informations forums :
    Inscription : Février 2012
    Messages : 6
    Par défaut Comment ne calculer une donnée qu'une fois
    Bonjour à tous,

    je vois explique mon problème avec un exemple.

    J'ai une requête qui me ramène ces informations :
    pporte_code famprd gamprd
    12 F1 null
    12 null G1
    12 null G1
    12 null null
    13 null null
    13 F2 null

    dans une requête imbriquée je calcule un temps d'après le famprd et le gamprd via une procédure.
    Mais ce temps il faut que je ne le calcule qu'une fois par "couple" : pporte_code,famprd,gamprd

    Ensuite, il faut que je prenne que le max par pporte_code pour à la fin n'en ramener qu'un.

    Dans mon exemple, ma requête imbriquée me donnerait le résultat si on ne prend qu'un temps par couple.
    pporte_code famprd gamprd temps
    12 F1 null 3.1
    12 null G1 5.2
    12 null G1 0
    12 null null 4.5
    13 null null 2.6
    13 F2 null 3.2

    Et au final je voudrais avoir :
    pporte_code famprd gamprd temps
    12 F1 null 0
    12 null G1 5.2
    12 null G1 0
    12 null null 0
    13 null null 0
    13 F2 null 3.2

    soit un seul temps (le max) par pporte_code.

    Voilà ma requête bon courage pour la lecture :
    ce qui m'intéresse c'est le tps_nb_cmde
    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
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    833
    834
    835
    836
    837
    838
    839
    840
    841
    842
    843
    844
    845
    846
    847
    848
    849
    850
    851
    852
    853
    854
    855
    856
    857
    SELECT fin.*
                ,rprs.reqp_code
          FROM   (SELECT rzgeo_code
                         ,GROUPING(rzgeo_code) col_rzgeo_code
                         ,rprs_code
                         ,GROUPING(rprs_code) col_rprs_code
                         ,
                          --nb commandes
                         ,SUM(DECODE(pporte_num
                                    ,1
                                    ,1
                                    ,0) * NVL(max_tps_nb_cmde
                                             ,0)) p_retour_tps_theo_cmde_raf
                          --nb prises
                         ,SUM(nb_prise_raf * DECODE(tps_nb_prises
                                                   ,NULL
                                                   ,0
                                                   ,tps_nb_prises)) p_retour_tps_theo_prise_raf
     
                   FROM   (SELECT NVL(soper_rprs_code
                                      ,poper_rprs_code) rprs_code
                                  ,rzgeo_code
                                  ,dossier
                                  ,fam_prd
                                  ,gam_prd
                                  ,MAX(tps_nb_fic_prep) keep(dense_rank LAST ORDER BY tps_nb_fic_prep) over(PARTITION BY pficpre_code) max_tps_nb_fic_prep
                                  ,MAX(tps_nb_um_det) keep(dense_rank LAST ORDER BY tps_nb_um_det) over(PARTITION BY pfat_psscc_code) max_tps_nb_um_det
                                  /*,MAX(tps_nb_cmde) keep(dense_rank LAST ORDER BY tps_nb_cmde) over(PARTITION BY pporte_code) max_tps_nb_cmde --30012012 a supprime*/
                                  , (select max(tps_nb_cmde) max_tps_nb_cmde from clefs )order by pporte_code 
                                  ,tps_nb_ul
                                  ,tps_nb_fic_prep
                                  ,tps_nb_ul_pv_det
                                  ,tps_nb_ul_pf_det
                                  ,tps_nb_prises
                                  ,tps_nb_um_hom
                                  ,tps_nb_um_det
                                  ,tps_nb_cmde
                                  ,NVL(DECODE(pfat_code
                                             ,NULL
                                             ,0
                                             ,DECODE(pfat_num
                                                    ,1
                                                    ,DECODE(pfat_l_etat
                                                           ,'E'
                                                           ,pfat_nb_ul
                                                           ,0)
                                                    ,0))
                                      ,0) vt1_lignes
                                  ,NVL(nvl2(smvt_code
                                           ,DECODE(smvt_num
                                                  ,1
                                                  ,smvt_nb_ul
                                                  ,0)
                                           ,0)
                                      ,0) vt2_lignes
                                  ,NVL(CASE
                                         WHEN pfat_l_etat = 'E' THEN
                                          DECODE(pfat_rub_typ
                                                ,'10'
                                                ,pfat_nb_ul * DECODE(pfat_num
                                                                    ,1
                                                                    ,1
                                                                    ,0)
                                                ,0)
                                         ELSE
                                          0
                                       END
                                      ,0) v1_nb_ul_var_4t
                                  ,NVL(CASE
                                         WHEN pfat_l_etat = 'E' THEN
                                          DECODE(pfat_rub_typ
                                                ,'01'
                                                ,pfat_nb_ul * DECODE(pfat_num
                                                                    ,1
                                                                    ,1
                                                                    ,0)
                                                ,0)
                                         ELSE
                                          0
                                       END
                                      ,0) v1_nb_ul_fix_4t
                                  ,NVL(DECODE(smvt_rub_typ
                                             ,'10'
                                             ,smvt_nb_ul * DECODE(smvt_num
                                                                 ,1
                                                                 ,1
                                                                 ,0)
                                             ,0)
                                      ,0) v2_nb_ul_var_4t
                                  ,NVL(DECODE(smvt_rub_typ
                                             ,'01'
                                             ,smvt_nb_ul * DECODE(smvt_num
                                                                 ,1
                                                                 ,1
                                                                 ,0)
                                             ,0)
                                      ,0) v2_nb_ul_fix_4t
                                  ,NVL(DECODE(pporte_l_trt
                                             ,0
                                             ,pporde_nb_ann
                                             ,0)
                                      ,0) vr1_lignes
                                  ,NVL(nvl2(pporde_nb_rec
                                           ,0
                                           ,DECODE(pporte_l_trt
                                                  ,9
                                                  ,pporde_nb_ann
                                                  ,0))
                                      ,0) vr2_lignes
                                  ,NVL(DECODE(pfat_l_etat
                                             ,'A'
                                             ,pfat_nb_ul
                                             ,0)
                                      ,0) vr3_lignes
                                  ,NVL(DECODE(pporte_l_trt
                                             ,0
                                             ,1
                                             ,0) * DECODE(pporde_rub_typ
                                                         ,'10'
                                                         ,pporde_nb_ann
                                                         ,0)
                                      ,0) nb_ul_v_1
                                  ,NVL(DECODE(pporte_l_trt
                                             ,0
                                             ,1
                                             ,0) * DECODE(pporde_rub_typ
                                                         ,'01'
                                                         ,pporde_nb_ann
                                                         ,0)
                                      ,0) nb_ul_f_1
                                  ,NVL(DECODE(pfat_l_etat
                                             ,'A'
                                             ,1
                                             ,0) * DECODE(pfat_rub_typ
                                                         ,'10'
                                                         ,pfat_nb_ul
                                                         ,0)
                                      ,0) nb_ul_v_2
                                  ,NVL(DECODE(pfat_l_etat
                                             ,'A'
                                             ,1
                                             ,0) * DECODE(pfat_rub_typ
                                                         ,'01'
                                                         ,pfat_nb_ul
                                                         ,0)
                                      ,0) nb_ul_f_2
                                  ,NVL(nvl2(pporde_nb_rec
                                           ,0
                                           ,1) * DECODE(pporte_l_trt
                                                       ,9
                                                       ,1
                                                       ,0) * DECODE(pporde_rub_typ
                                                                   ,'10'
                                                                   ,pporde_nb_ann
                                                                   ,0)
                                      ,0) nb_ul_v_3
                                  ,NVL(nvl2(pporde_nb_rec
                                           ,0
                                           ,1) * DECODE(pporte_l_trt
                                                       ,9
                                                       ,1
                                                       ,0) * DECODE(pporde_rub_typ
                                                                   ,'01'
                                                                   ,pporde_nb_ann
                                                                   ,0)
                                      ,0) nb_ul_f_3
                                  ,CASE
                                     WHEN pfat_pficpre_b_valid = 'N'
                                          AND pfat_pficpre_code_num = 1 THEN
                                      1
                                     ELSE
                                      0
                                   END v1_nb_ficpre_raf
                                  ,CASE
                                     WHEN pfat_pficpre_b_valid = 'O'
                                          AND pfat_pficpre_code_num = 1 THEN
                                      1
                                     ELSE
                                      0
                                   END v1_nb_ficpre_t
                                  ,CASE
                                     WHEN smvt_pficpre_b_valid = 'O'
                                          AND smvt_pficpre_code_num = 1 THEN
                                      1
                                     ELSE
                                      0
                                   END v2_nb_ficpre_t
                                  ,NVL((nvl2(pfat_code
                                            ,1
                                            ,0) * DECODE(pfat_num
                                                         ,1
                                                         ,1
                                                         ,0) * DECODE(pfat_l_etat
                                                                      ,'E'
                                                                      ,1
                                                                      ,0) * pfat_nb_ul) / pfat_rul_nb_ul_prise
                                      ,0) nb_prise_ter
                                  ,NVL((DECODE(pfat_l_etat
                                              ,'A'
                                              ,1
                                              ,0) * pfat_nb_ul) / pfat_rul_nb_ul_prise
                                      ,0) nb_prise_raf
                                  ,NVL(CASE
                                         WHEN pfat_rtmvts_code IN ('PHOM')
                                              AND pfat_l_etat = 'E'
                                              AND pfat_rub_typ = '01' THEN
                                          pfat_nb_ul
                                         ELSE
                                          0
                                       END
                                      ,0) nb_pfat_psscc_hom_ter_pf
                                  ,NVL(CASE
                                         WHEN pfat_rtmvts_code IN ('PHOM')
                                              AND pfat_l_etat = 'E'
                                              AND pfat_rub_typ = '10' THEN
                                          pfat_nb_ul
                                         ELSE
                                          0
                                       END
                                      ,0) nb_pfat_psscc_hom_ter_pv
                                  ,NVL(CASE
                                         WHEN smvt_rtmvts_code IN ('PHOM')
                                              AND smvt_rub_typ = '01' THEN
                                          smvt_nb_ul
                                         ELSE
                                          0
                                       END
                                      ,0) nb_smvt_psscc_hom_ter_pf
                                  ,NVL(CASE
                                         WHEN smvt_rtmvts_code IN ('PHOM')
                                              AND smvt_rub_typ = '10' THEN
                                          smvt_nb_ul
                                         ELSE
                                          0
                                       END
                                      ,0) nb_smvt_psscc_hom_ter_pv
                                  ,pporte_code
                                  ,pporte_num
                                   -- pds brut annonce fixe
                                  ,NVL(CASE
                                         WHEN pfat_rub_typ = '01' THEN
                                          pporde_pds_brut_ann
                                         ELSE
                                          0
                                       END
                                      ,0) pds_pfat_brut_ann_f
                                   -- pds brut annonce variable
                                  ,NVL(CASE
                                         WHEN pfat_rub_typ = '10' THEN
                                          pporde_pds_brut_ann
                                         ELSE
                                          0
                                       END
                                      ,0) pds_pfat_brut_ann_v
                                   -- pds net annonce fixe
                                  ,NVL(CASE
                                         WHEN pfat_rub_typ = '01' THEN
                                          pporde_pds_net_ann
                                         ELSE
                                          0
                                       END
                                      ,0) pds_pfat_net_ann_f
                                   -- pds net annonce variable
                                  ,NVL(CASE
                                         WHEN pfat_rub_typ = '10' THEN
                                          pporde_pds_net_ann
                                         ELSE
                                          0
                                       END
                                      ,0) pds_pfat_net_ann_v
                                   -- pds net reel fixe
                                  ,NVL(CASE
                                         WHEN pfat_rub_typ = '01' THEN
                                          pporde_pds_net_reel
                                         ELSE
                                          0
                                       END
                                      ,0) pds_pfat_net_reel_f
                                  ,NVL(CASE
                                         WHEN smvt_rub_typ = '01' THEN
                                          pporde_pds_net_reel
                                         ELSE
                                          0
                                       END
                                      ,0) pds_smvt_net_reel_f
                                   -- pds net reel variable
                                  ,NVL(CASE
                                         WHEN pfat_rub_typ = '10' THEN
                                          pporde_pds_net_reel
                                         ELSE
                                          0
                                       END
                                      ,0) pds_pfat_net_reel_v
                                  ,NVL(CASE
                                         WHEN smvt_rub_typ = '10' THEN
                                          pporde_pds_net_reel
                                         ELSE
                                          0
                                       END
                                      ,0) pds_smvt_net_reel_v
                                   -- pds brut reel fixe
                                  ,NVL(CASE
                                         WHEN pfat_rub_typ = '01' THEN
                                          pporde_pds_brut_reel
                                         ELSE
                                          0
                                       END
                                      ,0) pds_pfat_brut_reel_f
                                  ,NVL(CASE
                                         WHEN smvt_rub_typ = '01' THEN
                                          pporde_pds_brut_reel
                                         ELSE
                                          0
                                       END
                                      ,0) pds_smvt_brut_reel_f
                                   -- pds brut reel variable
                                  ,NVL(CASE
                                         WHEN pfat_rub_typ = '10' THEN
                                          pporde_pds_brut_reel
                                         ELSE
                                          0
                                       END
                                      ,0) pds_pfat_brut_reel_v
                                  ,NVL(CASE
                                         WHEN smvt_rub_typ = '10' THEN
                                          pporde_pds_brut_reel
                                         ELSE
                                          0
                                       END
                                      ,0) pds_smvt_brut_reel_v
                                  ,tps_pds_net_f
                                  ,tps_pds_net_v
                                  ,tps_pds_brut_f
                                  ,tps_pds_brut_v
                                  ,tps_nb_ul_pv_homo
                                  ,tps_nb_ul_pf_homo
                                  ,tps_nb_lig
                                  ,NVL(CASE
                                         WHEN smvt_rul_sup_dir = 'O'
                                              AND smvt_rtmvts_code IN ('PPIC', 'PRES', 'PHOM') THEN
                                          1
                                         ELSE
                                          NULL
                                       END
                                      ,0) nb_sup_dir_smvt_rea
                                   -- aga modif debut
                                  ,NVL(CASE
                                         WHEN pfat_rul_sup_dir = 'O'
                                              AND pfat_l_etat = 'E'
                                              AND pfat_rtmvts_code IN ('PPIC', 'PRES', 'PHOM') THEN
                                          1
                                         ELSE
                                          NULL
                                       END
                                      ,0) nb_sup_dir_pfat_rea
                                   -- aga modif fin
                                  ,NVL(CASE
                                         WHEN pfat_rtmvts_code = 'PHOM'
                                              AND pfat_l_etat = 'E' THEN
                                          pfat_psscc_code_num
                                         ELSE
                                          NULL
                                       END
                                      ,0) pfat_nb_sp_homo_rea
                                  ,NVL(CASE
                                         WHEN smvt_rtmvts_code = 'PHOM' THEN
                                          smvt_psscc_code_num
                                         ELSE
                                          NULL
                                       END
                                      ,0) smvt_nb_sp_homo_rea
                                  ,NVL(CASE
                                         WHEN pfat_rtmvts_code IN ('PPIC', 'PRES')
                                              AND pfat_l_etat = 'E' THEN
                                          pfat_psscc_code_num
                                         ELSE
                                          NULL
                                       END
                                      ,0) pfat_nb_sp_hete_rea
                                  ,NVL(CASE
                                         WHEN smvt_rtmvts_code IN ('PPIC', 'PRES') THEN
                                          smvt_psscc_code_num
                                         ELSE
                                          NULL
                                       END
                                      ,0) smvt_nb_sp_hete_rea
                                   --nb ul hétérogène pf pfat
                                  ,NVL(CASE
                                         WHEN pfat_rtmvts_code IN ('PPIC', 'PRES')
                                              AND pfat_l_etat = 'E'
                                              AND pfat_psscc_num = 0
                                              AND pfat_rub_typ = '01' THEN
                                          pfat_nb_ul
                                         ELSE
                                          0
                                       END
                                      ,0) pfat_nb_ul_hete_pf_rea
                                   --nb ul hétérogène pv pfat
                                  ,NVL(CASE
                                         WHEN pfat_rtmvts_code IN ('PPIC', 'PRES')
                                              AND pfat_l_etat = 'E'
                                              AND pfat_psscc_num = 0
                                              AND pfat_rub_typ = '10' THEN
                                          pfat_nb_ul
                                         ELSE
                                          0
                                       END
                                      ,0) pfat_nb_ul_hete_pv_rea
                                   --nb ul hétérogène pf smvt
                                  ,NVL(CASE
                                         WHEN smvt_rtmvts_code IN ('PPIC', 'PRES')
                                              AND smvt_rub_typ = '01' THEN
                                          smvt_nb_ul
                                         ELSE
                                          NULL
                                       END
                                      ,0) smvt_nb_ul_hete_pf_rea
                                   --nb ul hétérogène pv smvt
                                  ,NVL(CASE
                                         WHEN smvt_rtmvts_code IN ('PPIC', 'PRES')
                                              AND smvt_rub_typ = '10' THEN
                                          smvt_nb_ul
                                         ELSE
                                          NULL
                                       END
                                      ,0) smvt_nb_ul_hete_pv_rea
                                   --aga ajout debut
                                   --nb psscc homogène raf
                                  ,NVL(CASE
                                         WHEN pporte_l_trt = 0
                                              AND pfat_rtmvts_code = 'PHOM' THEN
                                          pfat_psscc_code_num
                                         ELSE
                                          NULL
                                       END
                                      ,0) pfat_nb_sp_homo_1_raf
                                  ,NVL(CASE
                                         WHEN pporte_l_trt = 9
                                              AND pfat_l_etat = 'A'
                                              AND pfat_rtmvts_code = 'PHOM' THEN
                                          pfat_psscc_code_num
                                         ELSE
                                          NULL
                                       END
                                      ,0) pfat_nb_sp_homo_2_raf
                                   -- nombre de support directionnel raf
                                  ,NVL(CASE
                                         WHEN pporte_l_trt = 0
                                              AND pfat_rul_sup_dir = 'O'
                                              AND pfat_rtmvts_code IN ('PPIC', 'PRES', 'PHOM') THEN
                                          1
                                         ELSE
                                          NULL
                                       END
                                      ,0) nb_sup_dir_pfat_1_raf
                                  ,NVL(CASE
                                         WHEN pporte_l_trt = 9
                                              AND pfat_l_etat = 'A'
                                              AND pfat_rul_sup_dir = 'O'
                                              AND pfat_rtmvts_code IN ('PPIC', 'PRES', 'PHOM') THEN
                                          1
                                         ELSE
                                          NULL
                                       END
                                      ,0) nb_sup_dir_pfat_2_raf
                                   -- nombre de support heterogène raf
                                  ,NVL(CASE
                                         WHEN pfat_rtmvts_code IN ('PPIC', 'PRES')
                                              AND pporte_l_trt = 0 THEN
                                          pfat_psscc_code_num
                                         ELSE
                                          NULL
                                       END
                                      ,0) pfat_nb_sp_hete_1_raf
                                  ,NVL(CASE
                                         WHEN pfat_rtmvts_code IN ('PPIC', 'PRES')
                                              AND pporte_l_trt = 9
                                              AND pfat_l_etat = 'A' THEN
                                          pfat_psscc_code_num
                                         ELSE
                                          NULL
                                       END
                                      ,0) pfat_nb_sp_hete_2_raf
                                   --nb ul hétérogène pf pfat raf
                                  ,NVL(CASE
                                         WHEN pfat_rtmvts_code IN ('PPIC', 'PRES')
                                              AND pporte_l_trt = 0
                                              AND pfat_psscc_num = 0
                                              AND pfat_rub_typ = '01' THEN
                                          pfat_nb_ul
                                         ELSE
                                          0
                                       END
                                      ,0) pfat_nb_ul_hete_pf_1_raf
                                  ,NVL(CASE
                                         WHEN pfat_rtmvts_code IN ('PPIC', 'PRES')
                                              AND pporte_l_trt = 9
                                              AND pfat_l_etat = 'A'
                                              AND pfat_psscc_num = 0
                                              AND pfat_rub_typ = '01' THEN
                                          pfat_nb_ul
                                         ELSE
                                          0
                                       END
                                      ,0) pfat_nb_ul_hete_pf_2_raf
                                   --nb ul hétérogène pv pfat
                                  ,NVL(CASE
                                         WHEN pfat_rtmvts_code IN ('PPIC', 'PRES')
                                              AND pporte_l_trt = 0
                                              AND pfat_psscc_num = 0
                                              AND pfat_rub_typ = '10' THEN
                                          pfat_nb_ul
                                         ELSE
                                          0
                                       END
                                      ,0) pfat_nb_ul_hete_pv_1_raf
                                  ,NVL(CASE
                                         WHEN pfat_rtmvts_code IN ('PPIC', 'PRES')
                                              AND pporte_l_trt = 9
                                              AND pfat_l_etat = 'A'
                                              AND pfat_psscc_num = 0
                                              AND pfat_rub_typ = '10' THEN
                                          pfat_nb_ul
                                         ELSE
                                          0
                                       END
                                      ,0) pfat_nb_ul_hete_pv_2_raf
                                   --nb ul homogène pf pfat
                                  ,NVL(CASE
                                         WHEN pfat_rtmvts_code IN ('PHOM')
                                              AND pporte_l_trt = 0
                                              AND pfat_rub_typ = '01' THEN
                                          pfat_nb_ul
                                         ELSE
                                          0
                                       END
                                      ,0) nb_pfat_psscc_hom_raf_pf_1
                                  ,NVL(CASE
                                         WHEN pfat_rtmvts_code IN ('PHOM')
                                              AND pporte_l_trt = 9
                                              AND pfat_l_etat = 'A'
                                              AND pfat_rub_typ = '01' THEN
                                          pfat_nb_ul
                                         ELSE
                                          0
                                       END
                                      ,0) nb_pfat_psscc_hom_raf_pf_2
                                   --nb ul homogène pv pfat
                                  ,NVL(CASE
                                         WHEN pfat_rtmvts_code IN ('PHOM')
                                              AND pporte_l_trt = 0
                                              AND pfat_rub_typ = '10' THEN
                                          pfat_nb_ul
                                         ELSE
                                          0
                                       END
                                      ,0) nb_pfat_psscc_hom_raf_pv_1
                                  ,NVL(CASE
                                         WHEN pfat_rtmvts_code IN ('PHOM')
                                              AND pporte_l_trt = 9
                                              AND pfat_l_etat = 'A'
                                              AND pfat_rub_typ = '10' THEN
                                          pfat_nb_ul
                                         ELSE
                                          0
                                       END
                                      ,0) nb_pfat_psscc_hom_raf_pv_2
     
                            --aga ajout fin
                            FROM   (SELECT (SELECT rprs_code
                                             FROM   soper
                                             WHERE  soper.pficpre_code = clefs.pficpre_code) soper_rprs_code
                                           ,(SELECT rprs_code
                                             FROM   poper
                                             WHERE  poper.pficpre_code = clefs.pficpre_code) poper_rprs_code
                                           ,clefs.rzgeo_code
                                           ,dossier
                                           ,fam_prd
                                           ,gam_prd
                                           ,clefs.pficpre_code
                                           ,pporte_l_trt
                                           ,pporde_nb_ann
                                           ,pporde_nb_rec
                                           ,pporde_rub_typ
                                           ,clefs.pfat_code
                                           ,pfat_num
                                           ,pfat_pficpre_code_num
                                           ,pfat_nb_ul
                                           ,pfat_l_etat
                                           ,pfat_rtmvts_code
                                           ,pfat_rub_typ
                                           ,pfat_pficpre_b_valid
                                           ,clefs.smvt_code
                                           ,smvt_num
                                           ,smvt_pficpre_code_num
                                           ,smvt_nb_ul
                                           ,smvt_rtmvts_code
                                           ,smvt_rub_typ
                                           ,smvt_pficpre_b_valid
                                           ,pficpre_l_typ_proc
                                           ,pfat_l_stt
                                           ,smvt_l_stt
                                           ,pfat_rul_nb_ul_prise
                                           ,pporte_code
                                            -- aga ajout pporte_code dans l'appel à fn_cal_tps_std et suppression de '854'
                                        ,pkg_calcul_charges_v3.fn_cal_tps_std(pporte_code
                                                                             ,clefs.dossier
                                                                             ,clefs.fam_prd
                                                                             ,clefs.gam_prd
                                                                             ,'IND_3_2'
                                                                             ,'PREPARATION'
                                                                             ,NULL) tps_nb_cmde
                                        ,pkg_calcul_charges_v3.fn_cal_tps_std(pporte_code
                                                                             ,clefs.dossier
                                                                             ,clefs.fam_prd
                                                                             ,clefs.gam_prd
                                                                             ,'IND_3_44'
                                                                             ,'PREPARATION'
                                                                             ,NULL) tps_nb_ul
                                        ,pkg_calcul_charges_v3.fn_cal_tps_std(pporte_code
                                                                             ,clefs.dossier
                                                                             ,clefs.fam_prd
                                                                             ,clefs.gam_prd
                                                                             ,'IND_3_15'
                                                                             ,'PREPARATION'
                                                                             ,NULL) tps_nb_ul_pv_homo
                                        ,pkg_calcul_charges_v3.fn_cal_tps_std(pporte_code
                                                                             ,clefs.dossier
                                                                             ,clefs.fam_prd
                                                                             ,clefs.gam_prd
                                                                             ,'IND_3_9'
                                                                             ,'PREPARATION'
                                                                             ,NULL) tps_nb_ul_pf_homo
                                        ,pkg_calcul_charges_v3.fn_cal_tps_std(pporte_code
                                                                             ,clefs.dossier
                                                                             ,clefs.fam_prd
                                                                             ,clefs.gam_prd
                                                                             ,'IND_3_39'
                                                                             ,'PREPARATION'
                                                                             ,NULL) tps_pds_net_f
                                        ,pkg_calcul_charges_v3.fn_cal_tps_std(pporte_code
                                                                             ,clefs.dossier
                                                                             ,clefs.fam_prd
                                                                             ,clefs.gam_prd
                                                                             ,'IND_3_41'
                                                                             ,'PREPARATION'
                                                                             ,NULL) tps_pds_net_v
                                        ,pkg_calcul_charges_v3.fn_cal_tps_std(pporte_code
                                                                             ,clefs.dossier
                                                                             ,clefs.fam_prd
                                                                             ,clefs.gam_prd
                                                                             ,'IND_3_13'
                                                                             ,'PREPARATION'
                                                                             ,NULL) tps_pds_brut_f
                                        ,pkg_calcul_charges_v3.fn_cal_tps_std(pporte_code
                                                                             ,clefs.dossier
                                                                             ,clefs.fam_prd
                                                                             ,clefs.gam_prd
                                                                             ,'IND_3_19'
                                                                             ,'PREPARATION'
                                                                             ,NULL) tps_pds_brut_v
                                        ,pkg_calcul_charges_v3.fn_cal_tps_std(pporte_code
                                                                             ,clefs.dossier
                                                                             ,clefs.fam_prd
                                                                             ,clefs.gam_prd
                                                                             ,'IND_3_7'
                                                                             ,'PREPARATION'
                                                                             ,NULL) tps_nb_um_hom
                                        ,pkg_calcul_charges_v3.fn_cal_tps_std(pporte_code
                                                                             ,clefs.dossier
                                                                             ,clefs.fam_prd
                                                                             ,clefs.gam_prd
                                                                             ,'IND_3_8'
                                                                             ,'PREPARATION'
                                                                             ,NULL) tps_nb_um_det
                                        ,pkg_calcul_charges_v3.fn_cal_tps_std(pporte_code
                                                                             ,clefs.dossier
                                                                             ,clefs.fam_prd
                                                                             ,clefs.gam_prd
                                                                             ,'IND_3_4'
                                                                             ,'PREPARATION'
                                                                             ,NULL) tps_nb_lig
                                        ,pkg_calcul_charges_v3.fn_cal_tps_std(pporte_code
                                                                             ,clefs.dossier
                                                                             ,clefs.fam_prd
                                                                             ,clefs.gam_prd
                                                                             ,'IND_3_59'
                                                                             ,'PREPARATION'
                                                                             ,NULL) tps_nb_fic_prep
                                        ,pkg_calcul_charges_v3.fn_cal_tps_std(pporte_code
                                                                             ,clefs.dossier
                                                                             ,clefs.fam_prd
                                                                             ,clefs.gam_prd
                                                                             ,'IND_3_12'
                                                                             ,'PREPARATION'
                                                                             ,NULL) tps_nb_ul_pf_det
                                        ,pkg_calcul_charges_v3.fn_cal_tps_std(pporte_code
                                                                             ,clefs.dossier
                                                                             ,clefs.fam_prd
                                                                             ,clefs.gam_prd
                                                                             ,'IND_3_18'
                                                                             ,'PREPARATION'
                                                                             ,NULL) tps_nb_ul_pv_det
                                        ,pkg_calcul_charges_v3.fn_cal_tps_std(pporte_code
                                                                             ,clefs.dossier
                                                                             ,clefs.fam_prd
                                                                             ,clefs.gam_prd
                                                                             ,'IND_3_69'
                                                                             ,'PREPARATION'
                                                                             ,NULL) tps_nb_prises
                                        ,pporte_num
                                        ,pporde_pds_brut_ann
                                        ,pporde_pds_net_ann
                                        ,pporde_pds_net_reel
                                        ,pporde_pds_brut_reel
                                        ,pfat_rul_sup_dir
                                        ,smvt_rul_sup_dir
                                        ,pfat_psscc_code
                                        ,smvt_psscc_code
                                        ,pfat_psscc_code_num
                                        ,smvt_psscc_code_num
                                        ,pfat_psscc_num
                                  FROM   (SELECT pporte.rdoss_code dossier
                                                ,(SELECT rfampr.code
                                                  FROM   rul
                                                        ,rub
                                                        ,rfampr
                                                  WHERE  rub.rfampr_code = rfampr.code(+)
                                                  AND    rul.code = NVL(smvt.rul_code
                                                                       ,NVL(pfat.rul_code
                                                                           ,NVL(pporde.rul_code
                                                                               ,NULL)))
                                                  AND    rul.rub_code = rub.code
                                                  AND    rub.rsite_code = '854'
                                                  AND    rub.rdoss_code = rfampr.rdoss_code) fam_prd
                                                ,(SELECT rgampr.code
                                                  FROM   rgampr
                                                        ,rul
                                                        ,rub
                                                  WHERE  rul.code = NVL(smvt.rul_code
                                                                       ,NVL(pfat.rul_code
                                                                           ,NVL(pporde.rul_code
                                                                               ,NULL)))
                                                  AND    rul.rub_code = rub.code
                                                  AND    rub.rgampr_code = rgampr.code(+)) gam_prd
                                                ,pporte.l_trt pporte_l_trt
                                                ,pporde.nb_ann pporde_nb_ann
                                                ,pporde.nb_rec pporde_nb_rec
                                                ,(SELECT rub.l_typ
                                                  FROM   rub
                                                        ,rul
                                                  WHERE  rul.code = pporde.rul_code
                                                  AND    rub.code = rul.rub_code) pporde_rub_typ
                                                ,pfat.code pfat_code
                                                ,row_number() over(PARTITION BY pfat.code ORDER BY pfat.code) pfat_num
                                                ,row_number() over(PARTITION BY pfat.pficpre_code ORDER BY pfat.pficpre_code) pfat_pficpre_code_num
                                                ,pfat.nb_ul pfat_nb_ul
                                                ,pfat.l_etat pfat_l_etat
                                                ,pfat.rempl_code pfat_rempl_code
                                                ,pfat.rtmvts_code pfat_rtmvts_code
                                                ,(SELECT rub.l_typ
                                                  FROM   rub
                                                        ,rul
                                                  WHERE  rul.code = pfat.rul_code
                                                  AND    rub.code = rul.rub_code) pfat_rub_typ
                                                ,(SELECT rul.nb_ul_prise
                                                  FROM   rul
                                                  WHERE  rul.code = pfat.rul_code) pfat_rul_nb_ul_prise
                                                ,(SELECT pficpre.b_valid
                                                  FROM   pficpre
                                                  WHERE  pficpre.code = pfat.pficpre_code) pfat_pficpre_b_valid
                                                ,smvt.code smvt_code
                                                ,row_number() over(PARTITION BY smvt.code ORDER BY smvt.code) smvt_num
                                                ,row_number() over(PARTITION BY smvt.pficpre_code ORDER BY smvt.pficpre_code) smvt_pficpre_code_num
                                                ,smvt.nb_ul smvt_nb_ul
                                                ,smvt.rempl_code smvt_rempl_code
                                                ,smvt.rtmvts_code smvt_rtmvts_code
                                                ,(SELECT pficpre.b_valid
                                                  FROM   pficpre
                                                  WHERE  pficpre.code = smvt.pficpre_code) smvt_pficpre_b_valid
                                                ,(SELECT rub.l_typ
                                                  FROM   rub
                                                        ,rul
                                                  WHERE  rul.code = smvt.rul_code
                                                  AND    rub.code = rul.rub_code) smvt_rub_typ
                                                ,smvt.pporde_code smvt_pporde_code
                                                ,rempl.rzgeo_code
                                                ,(SELECT psscc.l_stt
                                                  FROM   psscc
                                                  WHERE  psscc.code = pfat.psscc_code) pfat_l_stt
                                                ,(SELECT psscc.l_stt
                                                  FROM   psscc
                                                  WHERE  psscc.code = smvt.psscc_code) smvt_l_stt
                                                ,smvt.pficpre_code smvt_pficpre_code
                                                ,pfat.pficpre_code pfat_pficpre_code
                                                ,(SELECT pficpre.l_typ_proc
                                                  FROM   pficpre
                                                  WHERE  pficpre.code = NVL(smvt.pficpre_code
                                                                           ,pfat.pficpre_code)) pficpre_l_typ_proc
                                                ,NVL(smvt.pficpre_code
                                                    ,pfat.pficpre_code) pficpre_code
                                                ,pporte.code pporte_code -- aga ajout pporte_code
                                                ,row_number() over(PARTITION BY pporte.code ORDER BY pporte.code) pporte_num --aga ajout de pporte num
                                                 -- aga ajout du poids
                                                ,pporde.pds_brut_ann pporde_pds_brut_ann
                                                ,pporde.pds_net_ann pporde_pds_net_ann
                                                ,pporde.pds_net_reel pporde_pds_net_reel
                                                ,pporde.pds_brut_reel pporde_pds_brut_reel
                                                ,(SELECT rul.b_sup_dir
                                                  FROM   rul
                                                  WHERE  rul.code = pfat.rul_code) pfat_rul_sup_dir
                                                ,(SELECT rul.b_sup_dir
                                                  FROM   rul
                                                  WHERE  rul.code = smvt.rul_code) smvt_rul_sup_dir
                                                ,pfat.psscc_code pfat_psscc_code
                                                ,smvt.psscc_code smvt_psscc_code
                                                ,row_number() over(PARTITION BY pfat.psscc_code ORDER BY pfat.psscc_code) pfat_psscc_code_num
                                                ,row_number() over(PARTITION BY smvt.psscc_code ORDER BY smvt.psscc_code) smvt_psscc_code_num
                                                ,COUNT(CASE
                                                         WHEN pfat.l_etat = 'A'
                                                              AND pporte.l_trt = '9' THEN
                                                          1
                                                         ELSE
                                                          NULL
                                                       END) over(PARTITION BY pfat.psscc_code) pfat_psscc_num
                                          FROM   pporte
                                                ,pporde
                                                ,pfat
                                                ,smvt
                                                ,rempl
                                          WHERE  EXISTS (SELECT 1
                                                  FROM   smvtul
                                                  WHERE  auutl_code = 'AGA'
                                                  AND    rdoss_code = pporte.rdoss_code)
                                          AND    pporte.rsite_code = '854'
                                          AND    pporte.code = pporde.pporte_code(+)
                                          AND    pporte.code = pfat.pporte_code(+)
                                          AND    pporte.code = smvt.pporte_code(+)
                                          AND    (pfat.pporde_code IS NULL OR pfat.pporde_code = pporde.code)
                                          AND    (smvt.pporde_code IS NULL OR smvt.pporde_code = pporde.code)
                                          AND    pporte.dhr_enlev BETWEEN '25/01/2012' AND '25/01/2012'
                                          AND    EXISTS (SELECT 1
                                                  FROM   rtmvts
                                                  WHERE  rtmvts.code_rgp = 'BL'
                                                  AND    rtmvts.b_stock = 'O'
                                                  AND    rtmvts.code = pfat.rtmvts_code)
                                          AND    rempl.code = NVL(smvt.rempl_code
                                                                 ,NVL(pfat.rempl_code
                                                                     ,NULL))) clefs) req) sql_groupe
                  GROUP  BY ROLLUP(rzgeo_code
                                  ,rprs_code)) fin
                ,rprs
          WHERE  col_rzgeo_code = 0
          AND    col_rprs_code = 0
          AND    fin.rprs_code = rprs.code(+)
          ORDER  BY fin.rzgeo_code
                   ,rprs_code DESC;
    Merci d'avance.

    astrid

  3. #3
    Modérateur
    Avatar de Waldar
    Homme Profil pro
    Sr. Specialist Solutions Architect @Databricks
    Inscrit en
    Septembre 2008
    Messages
    8 454
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Sr. Specialist Solutions Architect @Databricks
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2008
    Messages : 8 454
    Par défaut
    Il faudrait avoir un peu plus de matière pour creuser (i.e. des données), mais est-ce que vous ne vous compliquez pas la vie pour rien, de votre besoin j'ai compris que vous vouliez l'agrégat simple :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
      select max(tps_nb_cmde) as max_tps_nb_cmde
        from MaTable
    group by pporte_code

  4. #4
    Membre Expert Avatar de lola06
    Femme Profil pro
    Consultante en Business Intelligence
    Inscrit en
    Avril 2007
    Messages
    1 316
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 38
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Consultante en Business Intelligence
    Secteur : Service public

    Informations forums :
    Inscription : Avril 2007
    Messages : 1 316
    Par défaut
    Bonjour,

    Il nous manque votre requête.

  5. #5
    Membre Expert Avatar de lola06
    Femme Profil pro
    Consultante en Business Intelligence
    Inscrit en
    Avril 2007
    Messages
    1 316
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 38
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Consultante en Business Intelligence
    Secteur : Service public

    Informations forums :
    Inscription : Avril 2007
    Messages : 1 316
    Par défaut
    Déjà ligne 7 et 9 tu as deux virgules qui se suivent...

    ligne 29 : le ORDER BY ne me semble pas très correct ici

  6. #6
    Invité
    Invité(e)
    Par défaut
    Citation Envoyé par lola06 Voir le message
    Il nous manque votre requête.
    Ah ben là, maintenant, t'es servi !! Une belle requête de 857 lignes...

  7. #7
    Membre Expert Avatar de lola06
    Femme Profil pro
    Consultante en Business Intelligence
    Inscrit en
    Avril 2007
    Messages
    1 316
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 38
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Consultante en Business Intelligence
    Secteur : Service public

    Informations forums :
    Inscription : Avril 2007
    Messages : 1 316
    Par défaut
    Citation Envoyé par 7gyY9w1ZY6ySRgPeaefZ Voir le message
    Ah ben là, maintenant, t'es servi !! Une belle requête de 857 lignes...
    Effectivement, par contre j'apprécierais beaucoup l'utilisation des balises codes (bouton # de l'éditeur) et un peu de mise en forme.

  8. #8
    Modérateur
    Avatar de Waldar
    Homme Profil pro
    Sr. Specialist Solutions Architect @Databricks
    Inscrit en
    Septembre 2008
    Messages
    8 454
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Val de Marne (Île de France)

    Informations professionnelles :
    Activité : Sr. Specialist Solutions Architect @Databricks
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2008
    Messages : 8 454
    Par défaut
    J'ai fusionné les deux discussions puisqu'il s'agit du même besoin.

  9. #9
    Membre du Club
    Femme Profil pro
    recette et qualification
    Inscrit en
    Février 2012
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations professionnelles :
    Activité : recette et qualification
    Secteur : Transports

    Informations forums :
    Inscription : Février 2012
    Messages : 6
    Par défaut merci
    pour vos remarques sur la forme c'est la première fois que je poste ici.
    Petite précision j'ai allégé ma requête d'où les 2 virgules qui se suivent.
    Elle fonctionne trés bien mais ne me renvoit pas ce que je veux.
    Merci d'avance à ceux qui auront une bonne idée.

  10. #10
    Membre chevronné
    Profil pro
    Inscrit en
    Février 2010
    Messages
    412
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2010
    Messages : 412
    Par défaut
    Bonjour,

    Pour votre remarque: premiere fois ou pas, une fois votre message poste vous auriez pus vous dire que les autres gens ont le code presente proprement dans un cadre special. Parce que sinon, c'est franchement illisible.

    Alors pour la prochaine fois, parce qu'on en apprends tous les jours, quand vous ecrivez un message au dessus de la zone de texte il y a les obutons gras, italique, etc. Sur la droite de cette barre, il y a un S barre, et juste avant un diese. C'est le bouton diese qui pose des balises [code] et dans lequel vous ecrivez votre code.

    Sinon, si j'ai bien compris un truc comme ca peut correspondre non?
    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
    TMP@MINILHC >select * from tmp;
     
             N N        VAL
    ---------- - ----------
             1 a          3
             1 b          0
             1 c          6
             2 a          4
             2 b          1
             3 a          1
     
    6 rows selected.
     
    Elapsed: 00:00:00.00
    TMP@MINILHC >with t1 as (select n,max(val) as max_val from tmp group by n)
      2     select tmp.n,tmp.n2, case when val=max_val then val else 0 end from tmp inner outer join t1 on tmp.n=t1.n order by 1,2;
     
             N N CASEWHENVAL=MAX_VALTHENVALELSE0END
    ---------- - ----------------------------------
             1 a                                  0
             1 b                                  0
             1 c                                  6
             2 a                                  4
             2 b                                  0
             3 a                                  1
     
    6 rows selected.
     
    Elapsed: 00:00:00.00
    Par contre, si il y a egalite c'est a vous de voir ce qu'il faut faire. Ici, on a deux resultats.

Discussions similaires

  1. Réponses: 4
    Dernier message: 25/01/2013, 08h38
  2. [Toutes versions] coller les données d'une plage d'une cellule dans une cellule d'une autre feuille[VBA]
    Par arthson dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 24/01/2012, 17h37
  3. Réponses: 2
    Dernier message: 18/12/2006, 19h04
  4. Réponses: 1
    Dernier message: 12/09/2006, 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