T+ 信息收集

eap_enumItem b on b.idEnum= N'32'  是eap_enumitem 表中的 父表主键中的编号为32 的是产品品牌的名称

/**这是将销售价异常的或者品牌为空的产品信息导出来 ---
未上架产品信息*/
select
i.priuserdefnvc4 as APP分类
,case when i.productInfo is null then '品牌为空' else '' end as 品牌
,case when p.invSCost1 < '1' or p.invSCost1 is null then 'APP销售价异常' else '' end as APP售价
,i.code as 编号
,i.name as 存货名
,i.specification as 规格
-- ,i.name+'('+u.name+')' as goods_info_name
,u.name as 单位
,u.changeRate as 转换率
,getdate() as 检查时间
from AA_InventoryPrice p right join dbo.AA_Inventory i on i.id = p.idinventory
left join [eap_userdefinearticledto_0001] appc on appc.name = i.priuserdefnvc4
left join dbo.AA_Unit u on p.idunit = u.id
left join (select idbaseunit,idinventory,sum(baseQuantity) baseQuantity from ST_CurrentStock where idwarehouse in (2,3) group by idbaseunit,idinventory) cs on i.id = cs.idinventory
left join (select sob.idinventory,sum(baseQuantity) as saleQuantity from SA_SaleOrder_b sob inner join SA_SaleOrder so on sob.idSaleOrderDTO = so.id left join [SA_SaleDelivery] sd on so.code = sd.SourceVoucherCode
where sd.code is null group by sob.idinventory) ss on ss.idinventory = i.id
left join eap_enumItem b on b.idEnum= N'32' and i.productInfo = b.id
where -- i.disabled = 0 and p.invSCost1 is not null and
i.priuserdefnvc4 is not null and i.priuserdefnvc4 > '' -- APP分类已设置
and( p.invSCost1 <'1' or p.invSCost1 is null -- 有APP销售价
or i.productInfo is null or i.productInfo ='' ) -- 品牌不为空
and i.disabled = 0 -- 非停用商品
-- and i.code= '010406'
-- and p.id = 281
-- and appc.code is null
order by i.code,u.name

猜你喜欢

转载自www.cnblogs.com/danJuly/p/10255033.html
今日推荐