SELECT
b.fname,case when c.FSupplyID=2518 then d.FAuxQty else 0 end '赊销金额',
case when c.FSupplyID=2518 then d.FDiscountAmount else 0 end '赊销折扣',
case when c.FSupplyID=2518 then d.FConsignAmount else 0 end '赊销净额',
case when c.FSupplyID=3321 then d.FAuxQty else 0 end '现销金额',
case when c.FSupplyID=3321 then d.FDiscountAmount else 0 end '现销折扣',
case when c.FSupplyID=3321 then d.FConsignAmount else 0 end '现销净额',
d.FAuxQty*FConsignPrice as '总金额',
d.FDiscountAmount as '总折扣',
d.FConsignAmount as '总净额',
c.fdate as '日期'
from [AIS20130930153452].[dbo].[t_ICItemBase] a inner join [AIS20130930153452].[dbo].[t_item] b on a.FItemID=b.FItemID
left join [AIS20130930153452].[dbo].[ICStockBill] c on a.FItemID=c.finterid
left join [AIS20130930153452].[dbo].[ICStockBillEntry] d on d.FInterID=c.FInterID
where b.FItemClassID=4
AND c.FTranType=21
这是查询语句 和 结果图,,,如果赊销和现销同时存在,要一起显示 后面的总额等要汇总赊销现销,怎么改。。。有能力你就放马过来吧