, . :
SELECT make, model, year, avg_price,
(avg_price + last_price + next_price) / (1.0 + last_cnt + next_cnt) AS 3_yr_center_average
FROM
(
SELECT t1.make, t1.model, t1.year, t1.avg_price,
COALESCE(t2.avg_price, 0) AS last_price,
COALESCE(t3.avg_price, 0) AS next_price,
CASE WHEN t2.avg_price IS NOT NULL THEN 1 ELSE 0 END AS last_cnt,
CASE WHEN t3.avg_price IS NOT NULL THEN 1 ELSE 0 END AS next_cnt
FROM yourTable t1
LEFT JOIN yourTable t2
ON t1.make = t2.make AND t1.model = t2.model AND t1.year = t2.year + 1
LEFT JOIN yourTable t3
ON t1.make = t3.make AND t1.model = t3.model AND t1.year = t3.year - 1
) t
ORDER BY
make, model, year;
, , , ( ) . . , , . , Subaru Forester 2013 17561
, 18533
2013 16589
.