乘以代码

时间:2018-02-01 07:12:09

标签: sql db2

我的查询没有结果,我不明白:

(
  select checkinkilometer 
  from rentobjtransact 
  where rentcontract.rentcontractid = rentobjtransact.rentcontractid 
  and RentObjTransact.isActive = 1
) *
(
  case when RentObj.isAlienRentObj = 0 
    then TO_CHAR(car.CO2Emission, '999999') 
    else rentobj.ClassificDescr3
  end
) - 
(
  select checkoutkilometer 
  from rentobjtransact 
  where rentcontract.rentcontractid = rentobjtransact.rentcontractid 
  and RentObjTransact.isActive = 1
) *
(
  case when RentObj.isAlienRentObj = 0
    then TO_CHAR(car.CO2Emission, '999999') 
    else rentobj.ClassificDescr3 
  end
) as "CO2 verbruik"

当我获取部分代码时,我得到的结果是正确的:

(
  select checkinkilometer 
  from rentobjtransact 
  where rentcontract.rentcontractid = rentobjtransact.rentcontractid 
  and RentObjTransact.isActive = 1
) -
(
  select checkoutkilometer 
  from rentobjtransact 
  where rentcontract.rentcontractid = rentobjtransact.rentcontractid 
  and RentObjTransact.isActive = 1
) as "km"

还有,

(
  case when RentObj.isAlienRentObj = 0 
    then TO_CHAR(car.CO2Emission, '999999') 
    else rentobj.ClassificDescr3 
  end
) as "CO2"

是对的。但是当我想要组合代码时,我得不到任何结果。请给我一个提示?

0 个答案:

没有答案