[英]How to avoid divide by zero error here?
我遇到的以下查詢遇到除以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
如何更換
(ld.income_base_rent_ach / ld.percentage_rent ) <> ld.turnover_threshold
同
ld.income_base_rent_ach <> (ld.percentage_rent * ld.turnover_threshold)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.