I have the following query which gives the current_rating value which I am after. However I am wondering how I then make this query update my table permanently so the current_rating value column permanently has this value.
***select *, r.current_rating from (select greydb.*, array_agg(race_rating) over (partition by greyhound order by date rows between 4 preceding and current row) as rating_5 from "greydb" ) t cross join lateral (select avg(r) as current_rating from (select u.* from unnest(t.rating_5) with ordinality u(r, n) where r is not null order by r desc limit 3 ) r ) r***