1

リンクの画像を見ると、Imploded Units to Average と Exploded Units to Sum が必要です。以下に示す結果の下にコードを添付します。私は数日間、これに対する答えを探していました。少し頭を悩ませてコーディングしようとしているのではないかと心配しています。

   SELECT A.to_load_id                                   AS "Cases", 
   A.from_qty - A.to_qty                          AS "Imploded Units", 
   ( A.from_qty - A.to_qty ) * Nvl(SUM(p.qty), 1) AS "Exploded Units", 
   A.wskusku                                      AS "Sku's", 
   A.wave                                         AS "Wave", 
   A.from_loc                                     AS "Processed Location", 
   A.free_form_text                               AS "Zone" ,

   FROM   audits A, 
   prepack P 
   WHERE  A.from_loc LIKE 'S%' 
   AND A.to_loc = A.from_loc 
   AND free_form_text IN ( '01', '02', '03', '04', 
                           '05', '06', '07', '08', 
                           '09', '10', '11', '12', 
                           '13', '14' ) 
   AND A.wskusku = p.sku (+) 
   AND A.from_load_id = '42419472' 
   AND A.wave in ('WC055193','','','','','','','','','')
   AND To_date(Substr(a.date_wms, 1, 12), 'YYYY/MM/DD HH24:MI') >= 
       SYSDATE - 4 
   GROUP  BY A.to_load_id, 
      A.from_qty, 
      A.to_qty, 
      P.qty, 
      A.wskusku, 
      A.wave, 
      A.from_loc, 
      A.free_form_text 
4

1 に答える 1

1

集計に含まれる列ではなくavg()/sum()を使用する必要があります。 GROUP BY

SELECT A.to_load_id                                    AS "Cases"
      ,avg(A.from_qty - A.to_qty)                      AS "Imploded Units"
      ,sum(A.from_qty - A.to_qty) * Nvl(SUM(P.qty), 1) AS "Exploded Units"
      ,A.wskusku                                       AS "Sku's"
      ,A.wave                                          AS "Wave"
      ,A.from_loc                                      AS "Processed Location"
      ,A.free_form_text                                AS "Zone"
FROM   audits A 
JOIN   prepack P ON P.sku (+) = A.wskusku
WHERE  A.from_loc LIKE 'S%' 
AND    A.to_loc = A.from_loc 
AND    A.free_form_text IN ( '01', '02', '03', '04', 
                           '05', '06', '07', '08', 
                           '09', '10', '11', '12', 
                           '13', '14' )
AND    A.from_load_id = '42419472'
AND    A.wave in ('WC055193','','','','','','','','','')
AND    To_date(Substr(A.date_wms, 1, 12), 'YYYY/MM/DD HH24:MI') >= SYSDATE - 4
GROUP  BY A.to_load_id, 
      ,A.wskusku
      ,A.wave
      ,A.from_loc
      ,A.free_form_text

を乗算する理由はわかりませんが、 は乗算しませ"Exploded Units""Imploded Units"。そこにあるものをコピーしました。

于 2012-12-09T17:40:47.233 に答える