I'm trying to put together a query that will order entries in a table by the rating values which decay over time. I'm not too well versed in the intricacies of Postgres, or complex queries, but I've cobbled the following together:
Code:
select * from entries order by (
select sum(-rating_value * exp(ln(0.5)/43200 *
extract(epoch from now() - rating_time)))
from ratings