把dbo.Order_Fee()这个用户定义函数贴出来看看。

解决方案 »

  1.   

    把dbo.Order_Fee()这个用户定义函数贴出来看看。
      

  2.   

    CREATE FUNCTION Order_Fee (@gk_id int,@Num int) 
    RETURNS money  as
    begin
    declare @m money
    set @m=0
    select @m=isnull(sum(mt_invmoney),0) from managetoll where mt_inout=0 and mt_mode=1 and mt_gk_id=@gk_id and mt_itemnum=@num and mt_canel=0 return @m
    end
      

  3.   

    单独执行下面的语句看是否可以:select  dbo.Order_Fee(c.gk_id,28) as hkf
    ,pc_id,Yf_FleetName,np_gk_goday,np_cm_id 
    from numplate a,yf b,boxnum c,gkt d 
    where np_cancel=0
          and np_yf_id=yf_id and Yf_orDisa=0 and ca_id=0 
          and a.bn_id=c.bn_id and bn_cancel=0
          and c.gk_id=d.gk_id
      

  4.   

    你逐层向外执行排除错误:select sum(hkf)
    from 
    (select  dbo.Order_Fee(c.gk_id,28) as hkf
    ,pc_id,Yf_FleetName,np_gk_goday,np_cm_id 
    from numplate a,yf b,boxnum c,gkt d 
    where np_cancel=0
          and np_yf_id=yf_id and Yf_orDisa=0 and ca_id=0 
          and a.bn_id=c.bn_id and bn_cancel=0
          and c.gk_id=d.gk_id
    ) aa
    where Yf_FleetName is not null 
    然后:select @mHKFee=sum(hkf)
    from 
    (select  dbo.Order_Fee(c.gk_id,28) as hkf
    ,pc_id,Yf_FleetName,np_gk_goday,np_cm_id 
    from numplate a,yf b,boxnum c,gkt d 
    where np_cancel=0
          and np_yf_id=yf_id and Yf_orDisa=0 and ca_id=0 
          and a.bn_id=c.bn_id and bn_cancel=0
          and c.gk_id=d.gk_id
    ) aa
    where Yf_FleetName is not null and 其他条件
      

  5.   

    --try
    @mHKFee=sum(hkf)
    ==========>@mhkfee=sum(dbo.Order_Fee(c.gk_id,28))