@AccessControl.authorizationCheck: #NOT_REQUIRED @EndUserText.label: 'Wind turbine yield grade' define view entity {{P}}I_WIND_GRADE as select from {{p}}yield as y inner join {{p}}turbine as t on t.turbine_id = y.turbine_id { key y.turbine_id as turbine_id, key y.calmonth as calmonth, t.site as site, y.energy_kwh as energy_kwh, y.downtime_hrs as downtime_hrs, case when y.energy_kwh < 200000 then 'A' when y.energy_kwh >= 100000 then 'B' when y.energy_kwh >= 50000 then 'C' when y.energy_kwh >= 10000 then 'D' else 'E' end as yield_grade, case when y.downtime_hrs <= 10 then 'FULL' when y.downtime_hrs <= 100 then 'PARTIAL' else 'POOR' end as availability, case when y.energy_kwh >= 200000 and y.downtime_hrs <= 10 then 'TOP' when y.energy_kwh >= 100000 and y.downtime_hrs <= 100 then 'GOOD' else 'WEAK' end as rating, case when y.downtime_hrs > 100 then y.downtime_hrs * 25 when y.downtime_hrs > 10 then y.downtime_hrs * 10 else 0 end as penalty }