SELECT t1.FBillNo AS 发票号码,
t3.FNumber as 客户编号,
t3.FName as 客户名称,
t4.FNumber as 物料编号,
t4.FName as 物料名称,
t6.FModel as 规格型号,
t5.FName as 单位,
t2.FQty AS 开票数量,
t2.FEntrySelfI0472 as 实开数量,
SUM(ISNULL(t2.FQty,0) - ISNULL(t2.FEntrySelfI0572,0) - ISNULL(t2.FEntrySelfI0472,0)) AS 未开票数量,
t2.FStdAmount as 开票金额,
SUM(ISNULL(t2.FEntrySelfI0573,0) + ISNULL(t2.FEntrySelfI0474,0)) as 实开金额
FROM ICSale t1
left join ICSaleEntry t2 ON t1.FInterID=t2.FInterID
left join t_Item t3 ON t1.FCustID=t3.FItemID
left join t_Item t4 ON t2.FItemID =t4.FItemID
left join t_Item t5 on t5.FItemID= t2.FUnitID
left join t_ICItem t6 on t6.FItemID=t2.FItemID
group by t3.FNumber,t3.FName, t4.FNumber,t4.FName,t2.FQty,t1.FBillNo,t5.FName,t2.FEntrySelfI0472,t6.FModel,t2.FStdAmount,t2.FEntrySelfI0573) a
where a.未开票数量>0
以上是写好的SQL语句,想可以按照物料编码和客户编号过滤。打开的时候像图1类似的效果
图1
推荐阅读