数据案例:采购退货数量汇总
小于 1 分钟
根据采购收货单汇总采购退货数量
SELECT T0.[DocEntry], T0.[LineNum], SUM(T1.[Quantity]) AS 'RQTY'
FROM PDN1 T0
INNER JOIN RPD1 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 PDN1 T0
INNER JOIN RPD1 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 PDN1 T0
INNER JOIN RPD1 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 PDN1 T0
INNER JOIN RPD1 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]