1

我的以下查询遇到除以 0 错误:

select  pp.building_name, 
        ld.tenant_trading_name,  
        tenancy_reference,  
        ld.turnover_threshold, 
        ld.percentage_rent, 
        ld.income_base_rent_ach, 
        ld.income_base_rent_ach / ld.percentage_rent as correct 
from 
    lease_deal.lease ld

inner join property.property pp
    on ld.building_id = pp.building_id

where 
    (ld.income_base_rent_ach / ld.percentage_rent ) <> ld.turnover_threshold
    and lease_status = 'APPROVED'
    and ld.progenesis_load_date is  null
order by pp.building_name

我已尝试通过执行以下操作来纠正此问题 - 但我收到语法错误,我不确定为什么?这里有什么语法错误?

select  pp.building_name, 
        ld.tenant_trading_name,  
        tenancy_reference,  
        ld.turnover_threshold, 
        ld.percentage_rent, 
        ld.income_base_rent_ach, 
        ld.income_base_rent_ach / ld.percentage_rent as correct 
from 
    lease_deal.lease ld

inner join property.property pp
    on ld.building_id = pp.building_id

where 
    case when ld.percentage_rent = 0
    then 1=1
    else ((ld.income_base_rent_ach / ld.percentage_rent ) <> ld.turnover_threshold)
    end
    and lease_status = 'APPROVED'
    and ld.progenesis_load_date is  null
order by pp.building_name
4

1 回答 1

3

怎么换

(ld.income_base_rent_ach / ld.percentage_rent ) <> ld.turnover_threshold

ld.income_base_rent_ach <> (ld.percentage_rent * ld.turnover_threshold)
于 2012-07-05T02:46:12.940 回答