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')