1

私が持っている次のクエリでは、ゼロ除算エラーが発生しています。

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 に答える