@AbapCatalog.sqlViewName: '{{p}}WGRD' @AbapCatalog.preserveKey: true @AccessControl.authorizationCheck: #NOT_REQUIRED @EndUserText.label: 'Wind turbine yield grade' define view {{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' else case when y.energy_kwh >= 100000 then 'B' else case when y.energy_kwh >= 50000 then 'C' else case when y.energy_kwh >= 10000 then 'D' else 'E' end end end end as yield_grade, case when y.downtime_hrs <= 10 then 'FULL' else case when y.downtime_hrs <= 100 then 'PARTIAL' else 'POOR' end end as availability, case when y.energy_kwh >= 200000 and y.downtime_hrs <= 10 then 'TOP' else case when y.energy_kwh >= 100000 and y.downtime_hrs <= 100 then 'GOOD' else 'WEAK' end end as rating, case when y.downtime_hrs > 100 then y.downtime_hrs * 25 else case when y.downtime_hrs > 10 then y.downtime_hrs * 10 else 0 end end as penalty }