select the last post - Mailing list pgsql-sql

From etur
Subject select the last post
Date
Msg-id 9febecb505041901502f116211@mail.gmail.com
Whole thread Raw
List pgsql-sql
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; 


pgsql-sql by date:

Previous
From: "Ramakrishnan Muralidharan"
Date:
Subject: Re: Debet-Credit-Balance Calculation
Next
From: Art - Feping
Date:
Subject: How to select from many database ??