sql 还能这样写

with o as (
 select orderid,ISNULL(UTaxRate,0) AS UTaxRate
 from [order] (nolock)
 where sourceid not in (21,22)
), l as (
 select o.orderid,oit.orderlineitemid,
  cast(o.UTaxRate as decimal(10,8)) as UTaxRate,
  cast(ISNULL(oit.TaxRate,0) as decimal(10,8)) as LineRate
 from o
 join dbo.Order_Line_Item oi (nolock)
  on oi.orderid=o.orderid
 join dbo.Order_Line_Item_Tax oit (nolock)
  on oit.orderlineitemid=oi.orderlineitemid
   and oit.TaxTypeId =215
)
select count(*) from l
where UTaxRate<>LineRate
posted on 2011-02-17 11:04  西湖浪子  阅读(138)  评论(0)    收藏  举报