下面这个sql语句,需要加一个(Taborders.Dates between :a and :b) ,但是不知道 加在什么地方,应该取这个表Taborders 的 Dates日期字段。,大家看看select c.dates as 日期,c.e as ID,c.ordercode as 订单号,tabsend_child.yunfei AS 发货运费,c.p as 运费,c.p-tabsend_child.yunfei as 运费毛利,(c.p-tabsend_child.yunfei)/c.p*6.8  as 运费毛利率  
from 
(select b.Id as e,Convert(varchar(10),b.Dates,120) as dates,a.code as ordercode,b.Prices-a.g as p from (select O_code as code,sum(gongji) as g from
taborder_clild group by O_code) a,Taborders b where a.code=b.ordercode and b.Prices-a.g>0  ) c,tabsend_child 
where c.ordercode=tabsend_child.ordercode   order by c.dates desc 

解决方案 »

  1.   


    select c.dates as 日期,c.e as ID,c.ordercode as 订单号,tabsend_child.yunfei AS 发货运费,c.p as 运费,c.p-tabsend_child.yunfei as 运费毛利,(c.p-tabsend_child.yunfei)/c.p*6.8  as 运费毛利率  
    from 
    (select b.Id as e,Convert(varchar(10),b.Dates,120) as dates,a.code as ordercode,b.Prices-a.g as p from (select O_code as code,sum(gongji) as g from 
    taborder_clild group by O_code) a,Taborders b where a.code=b.ordercode and b.Prices-a.g>0  and b.Dates between :a and :b) c,tabsend_child 
    where c.ordercode=tabsend_child.ordercode  order by c.dates desc 
      

  2.   

    谢谢哦,,simonhehe 你的可以用