postgresql7.1 select fm.message_id, fm.subject, fm.user_id, person__name(fm.user_id) as user_name, fm.posting_date, fm.state, (select count(*) from $forums_table fm1 where fm1.forum_id = :forum_id and fm1.tree_sortkey between tree_left(fm.tree_sortkey) and tree_right(fm.tree_sortkey)) as n_messages, to_char(fm.last_child_post, 'Mon DD YYYY HH24:MI:SS') as last_child_post, case when fm.last_child_post > (now() - 1) then 't' else 'f' end as new_p from forums_messages_approved fm where fm.forum_id = :forum_id and fm.parent_id is null order by fm.posting_date desc select fm.message_id, fm.subject, fm.user_id, person__name(fm.user_id) as user_name, fm.posting_date, fm.state, (select count(*) from $forums_table fm1 where fm1.forum_id = :forum_id and fm1.tree_sortkey between tree_left(fm.tree_sortkey) and tree_right(fm.tree_sortkey)) as n_messages, to_char(fm.last_child_post, 'Mon DD YYYY HH24:MI:SS') as last_child_post, case when fm.last_child_post > (now() - 1) then 't' else 'f' end as new_p from forums_messages fm where fm.forum_id = :forum_id and fm.parent_id is null and fm.message_id IN (CURRENT_PAGE_SET) order by fm.posting_date desc select fm.message_id, fm.subject, fm.user_id, person__name(fm.user_id) as user_name, fm.posting_date, fm.state, (select count(*) from $forums_table fm1 where fm1.forum_id = :forum_id and fm1.tree_sortkey between tree_left(fm.tree_sortkey) and tree_right(fm.tree_sortkey)) as n_messages, to_char(fm.last_child_post, 'Mon DD YYYY HH24:MI:SS') as last_child_post, case when fm.last_child_post > (now() - 1) then 't' else 'f' end as new_p from forums_messages_approved fm where fm.forum_id = :forum_id and fm.parent_id is null order by fm.last_child_post desc select fm.message_id, fm.subject, fm.user_id, person__name(fm.user_id) as user_name, fm.posting_date, fm.state, (select count(*) from $forums_table fm1 where fm1.forum_id = :forum_id and fm1.tree_sortkey between tree_left(fm.tree_sortkey) and tree_right(fm.tree_sortkey)) as n_messages, to_char(fm.last_child_post, 'Mon DD YYYY HH24:MI:SS') as last_child_post, case when fm.last_child_post > (now() - 1) then 't' else 'f' end as new_p from forums_messages fm where fm.forum_id = :forum_id and fm.parent_id is null and fm.message_id IN (CURRENT_PAGE_SET) order by fm.last_child_post desc