用于TOP 取最新商品价格、或是 明细的最后一条记录

列1  

select spdm,spmc,dwmc,bzsj
,bzsj as Fprice
,round(isnull(bzsj,0)*0.23,6) as FindustryPrice

from (
select v1.SPDM,v1.SPMC,v1.DWMC,
(case when V2.tzsj>0 then V2.tzsj else v1.BZSJ end) AS BZSJ
from bs_erp_shangpin v1
LEFT JOIN(

select spdm,tzsj  from bs_erp_spjgtz twhere t1.mxbh in (select top 1 mxbh from bs_erp_spjgtz where spdm=t1.spdm and tzrq <= rq and(qudm in or khdm=) order by tzrq desc)

) V2 ON V2.SPDM=V1.SPDM
) t

 

例 2


SELECT D.EDBObjID  FROM dbo.CW_JZB H ,dbo.CW_JZBD D
WHERE H.ObjectID  = D.ParentID
 AND D.ObjectID IN (SELECT TOP 1 ObjectID FROM dbo.CW_JZBD E WHERE E.ParentID = H.ObjectID ORDER BY E.Line DESC)
 AND H.FDJE != 0
 AND H.ObjectID IN ('5c3df382-989a-4b21-a056-d5a86150dbeb','8b3bac88-0d19-46ce-a8eb-9a3461a11844')

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值