postgresql7.1 select t.area_id, a.name as area_name, t.name, t.type, t.status, t.message, t.message_format, t.priority, to_char(t.deadline, 'YYYY-MM-DD') as deadline, t.url, ttl_relative_date(t.creation_date) as posting_date, person__name(t.creation_user) as posting_name from ttl_v_tickets t, ttl_va_areas a where a.context_id = :package_id and t.ticket_id = :ticket_id and t.area_id = a.area_id select * from (select p.first_names || ' ' || p.last_name as full_name, t.user_id, case when a.user_id is null then 0 else 1 end as already_assigned_p from ttl_v_users t left join (select user_id from ttl_assignments where ticket_id = :ticket_id) a using (user_id), persons p where t.package_id = :package_id and p.person_id = t.user_id order by upper(p.first_names)) b limit 50