您的位置:首页 > 产品设计 > UI/UE

一个获取Sales Order中Item价格的Query

2010-12-06 11:16 288 查看
一个获取Sales Order中Item价格的Query:

DECLARE @Price Numeric(19,6)
DECLARE @Dis Numeric(19,6)
DECLARE @DisPrice Numeric(19,6)

Set @Price = 0.0
Set @Dis = 0.0
Set @DisPrice = 0.0

SELECT top 1 @Price = price from [@PRICELIST] t1
where t1.itemcode = $[rdr1.itemcode] and substring(convert(char(4),convert(tinyint,t1.tradeterm)+1000),2,3) = $[ordr.U_tradecode] and t1.cardcode = $[ordr.CardCode] and
$[ordr.doccur] = t1.currency and
((t1.type = 'CO' and
$[ORDR.TaxDate] >= t1.effectivefrom and $[ORDR.TaxDate] <= isnull(t1.effectiveto,'29991231')) or
(t1.type = 'EX-FTY' and $[RDR1.ShipDate] >= t1.effectivefrom and $[RDR1.ShipDate] <= isnull(t1.effectiveto,'29991231'))) order by t1.sn desc

SELECT @Dis = isnull(discountrate,0) from [@discount] t0
inner join oitm on t0.itemcode = oitm.itemcode
where oitm.itemcode = $[rdr1.itemcode] and t0.cardcode = $[ORDR.CardCode] and
$[rdr1.U_ITEMTQ.Number] >= t0.qtyfrom
and $[rdr1.U_ITEMTQ.Number] <= IsNull(t0.qtyto,99999999)

SELECT Cast(Cast((100 - @Dis)/100 *@Price as decimal(12,6)) as char(13))
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: