select the last post

Поиск
Список
Период
Сортировка
От etur
Тема select the last post
Дата
Msg-id 9febecb505041901502f116211@mail.gmail.com
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: "Ramakrishnan Muralidharan"
Дата:
Сообщение: Re: Debet-Credit-Balance Calculation
Следующее
От: Art - Feping
Дата:
Сообщение: How to select from many database ??