在oracle视图,取相同字段值的和
在oracle中写了一个试图,我想加一个字段,取得是相同RD.SKU行的QTYGOOD的和
CREATE OR REPLACE VIEW aaa AS
SELECT
R.WHSEID,
RD.STORERKEY,
RD.SKU,
CASE
WHEN LOC.LOCATIONCATEGORY <> 'NG' AND RD.CONDITIONCODE = 'OK'
THEN RD.QTYRECEIVED
ELSE 0
END QTYGOOD
FROM RECEIPT R
LEFT JOIN RECEIPTDETAIL RD ON R.RECEIPTKEY = RD.RECEIPTKEY
LEFT JOIN RECEIPTDETAIL RD1 ON RD1.RECEIPTKEY = SUBSTR(RD.LOTTABLE03,1,10)
AND RD1.RECEIPTLINENUMBER = SUBSTR(RD.LOTTABLE03,11,5)
LEFT JOIN SKU SKU ON SKU.STORERKEY = RD.STORERKEY
AND SKU.SKU = RD.SKU
LEFT JOIN STORER S ON S.STORERKEY = RD.STORERKEY
AND S.TYPE='1'
LEFT JOIN STORER S1 ON S1.STORERKEY = RD.LOTTABLE06
AND S1.TYPE='1'
LEFT JOIN CODELKUP C ON C.CODE = R.TYPE
AND C.LISTNAME='RECEIPTYPE'
LEFT JOIN CODELKUP C1 ON C1.CODE = RD.LOTTABLE11
AND C1.LISTNAME='ISOCOUNTRY'
LEFT JOIN CODELKUP C2 ON C2.CODE = R.CUSTOMWAY
AND C2.LISTNAME='CUSTOMWAY'
LEFT JOIN LOC LOC ON LOC.LOC = RD.TOLOC
LEFT JOIN ALTSKU A ON A.STORERKEY = RD.STORERKEY AND A.SKU = RD.SKU
AND A.VENDOR = RD.LOTTABLE06 AND A.ALTSKU = RD.LOTTABLE07
AND A.UDF7 = RD.LOTTABLE08 AND A.UDF8 = RD.LOTTABLE09
WHERE R.STATUS= '11' AND RD.QTYRECEIVED > 0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论