数据案例:销售退货数量汇总
小于 1 分钟
根据销售交货单汇总销售交货单数量
SELECT T0.[DocEntry], T0.[LineNum], SUM(T1.[Quantity]) AS 'RQTY'
FROM DLN1 T0
INNER JOIN RDN1 T1
ON T1.[BaseEntry] = T0.[DocEntry]
AND T1.[BaseLine] = T0.[LineNum]
GROUP BY T0.[DocEntry], T0.[LineNum]
应用于销售交货单表,示例销售交货单行表为T1
- 示例代码
LEFT JOIN (
SELECT T0.[DocEntry], T0.[LineNum], SUM(T1.[Quantity]) AS 'RQTY'
FROM DLN1 T0
INNER JOIN RDN1 T1
ON T1.[BaseEntry] = T0.[DocEntry]
AND T1.[BaseLine] = T0.[LineNum]
GROUP BY T0.[DocEntry], T0.[LineNum]
) TS
ON TS.[DocEntry] = t1.docentry
AND TS.[LineNum] = T1.[LineNum]
根据销售交货单汇总销售退货数量,取销售订单号
SELECT T0.[BaseEntry], T0.[BaseLine], SUM(T1.[Quantity]) AS 'RQTY'
FROM DLN1 T0
INNER JOIN RDN1 T1
ON T1.[BaseEntry] = T0.[DocEntry]
AND T1.[BaseLine] = T0.[LineNum]
GROUP BY T0.[BaseEntry], T0.[BaseLine]
应用于销售订单表,示例销售订单单行表为T1
LEFT JOIN (
SELECT T0.[BaseEntry], T0.[BaseLine], SUM(T1.[Quantity]) AS 'RQTY'
FROM DLN1 T0
INNER JOIN RDN1 T1
ON T1.[BaseEntry] = T0.[DocEntry]
AND T1.[BaseLine] = T0.[LineNum]
GROUP BY T0.[BaseEntry], T0.[BaseLine]
) TR
ON TR.[BaseEntry] = t1.docentry
AND TR.[BaseLine] = T1.[LineNum]