postgresql7.1 select j.mail_job_id, j.mail_class_id, j.subject, j.state, to_char(j.scheduled_date, 'YYYY-MM-DD HH24:MI') as execution_date from ml_mail_jobs j where j.package_id = :package_id and j.state in ('suspended', 'active') and acs_permission__permission_p(j.mail_job_id, :user_id, 'admin') = 't' order by j.scheduled_date, lower(subject)