INCIDENT
行のあるテーブルがあります
TICKETID ACTUALFINISH TARGETFINISH
100 2012-03-01 11:11:11 2012-02-01 11:11:11
101 2012-03-01 11:11:11 2012-01-01 11:11:11
102 2012-04-01 11:11:11 2012-06-01 11:11:11
103 2012-05-01 11:11:11 2012-07-01 11:11:11
104 null null
target finish
より大きい行actual finish
と反対の行のパーセンテージで表示したい。
したがって、このテーブルの結果は次のようになります(null値は含まれません)。
SLA PERCENTAGE
YES 50
NO 50
SQLクエリを作成しましたが、エラーが発生し続けます。エラーがどこにあるのかわかりません。
最初に、AFがTFよりも大きい場合よりもレコードの総数を取得し、次にAFがTFよりも小さい場合を取得します。
with HELPTABLE as
(select count(*) as Total
from incident as incident4
where incident4.targetfinish is not null and incident4.actualfinish is not null )
select distinct case when incident.targetfinish>incident.actualfinish then
dec((( select count(*)
from incident as incident1
where incident1.targetfinish is not null and incident1.actualfinish is not null )),10,2)/HELPTABLE.Total*100
when incident.targetfinish<incident.actualfinish then
dec(((select count(*)
from incident as incident2
where incident2.targetfinish is not null and incident2.actualfinish is not null )),10,2)/HELPTABLE.Total*100
end as Percentage,
case when incident.targetfinish>incident.actualfinish then 'Yes'
when incident.targetfinish<incident.actualfinish then 'No'
end as SLA
from incident
where incident.targetfinish is not null and incident.actualfinish is not null
誰かがエラーが何であるかを知っているなら、ありがとう!
[エラーコード:-206、SQL状態:42703] DB2 SQLエラー:SQLCODE = -206、SQLSTATE = 42703、SQLERRMC = HELPTABLE.TOTAL、DRIVER = 3.57.82)