@AccessControl.authorizationCheck: #NOT_REQUIRED @EndUserText.label: 'Air quality per station' define view entity {{P}}I_AIR_QUALITY as select from {{p}}station as sta inner join {{p}}reading as rea on rea.station_id = sta.station_id { key sta.station_id as station_id, sta.station_name as station_name, count( * ) as reading_count, avg( rea.pm_value as abap.dec( 5, 1 ) ) as avg_pm, max( rea.pm_value ) as max_pm, case when max( rea.pm_value ) > sta.limit_pm then 'HIGH' when max( rea.pm_value ) > sta.limit_pm * 80 / 100 then 'MEDIUM' else 'LOW' end as rating, abs( max( rea.pm_value ) - sta.limit_pm ) as deviation } group by sta.station_id, sta.station_name, sta.limit_pm