hi there,
hi have a table called forum, and i've got this query:
this query select the messages and the number of replies to the
message individualy.
i'm trying to select the last post of each set of replies, like we see
in the foruns.
does anyone can help me
best regards,
etur
SELECT id, subject, to_char(post_time, 'YYYY.MM.DD @
HH24:MI:SS'::text) AS post_time,
content, login, messages.parent_id, replies.answered FROM ( SELECT f.id, f.subject, f.post_time, f.content, u.login,
f.parent_id FROM forum f, system_users u WHERE f.parent_id IS NULL AND f.user_id = u.id) messages LEFT
JOIN( SELECT forum.parent_id, count(forum.id) AS answered FROM forum GROUP BY
forum.parent_id)replies ON messages.id = replies.parent_id;