当查看链接中的图片时,我需要将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
答案 0 :(得分: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"
。我复制了那里的东西。