In my Postgres database table I can find the last 20 entries of cap_cs137
by date order:
select cap_cs137 FROM capintec ORDER BY cap_date DESC LIMIT 20;
I can also get the average:
select avg(cap_cs137) FROM capintec LIMIT 20;
However, how do I combine the above statements to get the average value for the last 20 entries by date order?
We have an outdated RHEL 5.8 server which supports Postgres 8.1.23 and therefore does not allow use of WITH
queries.