oracle8.1.6 select message_id, 0 as n_attachments, subject, content, person.name(user_id) as user_name, to_char(posting_date, 'Mon DD YYYY HH24:MI:SS') as posting_date, tree.tree_level(tree_sortkey) as tree_level, state, user_id from $table_name where forum_id = :forum_id and tree_sortkey between tree.left(:tree_sortkey) and tree.right(:tree_sortkey) order by $order_by select message_id, (select count(*) from attachments where object_id = message_id) as n_attachments, subject, content, person.name(user_id) as user_name, to_char(posting_date, 'Mon DD YYYY HH24:MI:SS') as posting_date, tree.tree_level(tree_sortkey) as tree_level, state, user_id from $table_name where forum_id = :forum_id and tree_sortkey between tree.left(:tree_sortkey) and tree.right(:tree_sortkey) order by $order_by