销售交货单明细(分批次显示数量)
小于 1 分钟
效果图
示例代码
SELECT T0.[Docentry] as'交货单号',T0.[CardName], T0.[NumAtCard], T0.[DocDueDate] AS '交货日期', T1.[ItemCode]
, T1.[Dscription], T1.[Quantity] as'总数量', Ta.[DistNumber] as'批次号',ta.qty as'批次数量',T0.[Comments]
FROM ODLN T0
INNER JOIN DLN1 T1 ON T0.[DocEntry] = T1.[DocEntry]
LEFT JOIN
(
SELECT T0.[ApplyEntry],T0.[ItemCode],T2.[DistNumber]
, -T1.[Quantity] AS'QTY'
FROM OITL T0
INNER JOIN ITL1 T1 ON T0.[LogEntry] = T1.[LogEntry]
INNER JOIN OBTN T2
ON T2.[SysNumber] = T1.[SysNumber]
AND T2.[ItemCode] = T1.[ItemCode]
WHERE T0.[ApplyType] =15
) TA ON Ta.[ApplyEntry]=T0.docentry AND Ta.[ItemCode]=t1.itemcode
WHERE T0.[DocDate] >= [%1]
AND T0.[DocDate] <= [%2]
ORDER BY T0.[DocNum] DESC