You can use UNPIVOT to create one row per kpi/value pair, then a regular aggregate query to get the average for each row from the source table.NOTE: I'm assuming that the source data is in a table named KPI, the values are INT, and there's a unique INT rowID for each row.;WITH CTEAS( SELECT rowID, kpi, value FROM KPI UNPIVOT(value FOR kpi IN (kpi1, kpi2, kpi3, kpi4, kpi5, kpi6, kpi7, kpi8, kpi9, kpi10)) u)SELECT rowID, SUM(CAST(value AS DEC)) / (4.0 * COUNT(*)) AS avg_value FROM CTE WHERE value < 5GROUP BY rowID;