Someone
public text v1 · immutableSELECT DISTINCT
t.id,
t.headline,
t.posted_at,
r.id
r.posted_at,
FROM threads AS t
JOIN replies AS r ON r.thread_id = t.id
ORDER BY
CASE
WHEN r.posted_at > t.posted_at THEN r.posted_at
ELSE t.posted_at
END DESC
LIMIT 100