Closed doryphores closed 11 years ago
Investigate LAG, LEAD sql:
SELECT *, GREATEST(d, p, n) lm
FROM (
SELECT publish_date pu,
updated_date d,
LAG(updated_date) OVER(ORDER BY publish_date DESC) p,
LEAD(updated_date) OVER(ORDER BY publish_date DESC) n
FROM apod_picture
) AS pd
WHERE pu = DATE '2012-06-30';
Currently last modified is set to current image last updated date but it needs to also take into account the previous and next images (otherwise, next and previous links may be incorrect).