oracle8.1.6
select t.ticket_id,
a.name as area_name,
decode(t.priority, 1, 'High',
2, 'Medium',
3, 'Low',
t.priority) as ticket_priority,
t.status,
s.sort_key,
t.name as ticket_name,
ttl_relative_date(nvl(c.creation_date, t.last_modified)) as last_comment,
decode(deadline, null, null, to_char(deadline, 'Mon DD')) as ticket_deadline
from ttl_va_tickets t, ttl_status s, ttl_va_areas a, ttl_v_comments_latest c
where a.context_id = :package_id and
a.area_id = t.area_id and
t.status = s.status and
t.ticket_id = c.ticket_id(+)
$user_id_clause
$status_clause
$area_clause
$order_clause
order by deadline asc, nvl(c.creation_date, t.last_modified) desc
order by nvl(c.creation_date, t.last_modified) desc
order by lower(area_name) asc, priority asc, nvl(c.creation_date, t.last_modified) desc
order by lower(s.sort_key) asc, priority asc, nvl(c.creation_date, t.last_modified) desc
order by priority asc, nvl(c.creation_date, t.last_modified) desc