postgresql7.4 select count(*) from evaluation_grades_sheets where task_id = :task_id and content_revision__is_live(grades_sheet_id) = true select egs.title as grades_sheet_name, to_char(egs.creation_date, 'YYYY-MM-DD HH24:MI:SS') as upload_date_ansi, person__name(egs.creation_user) as upload_user, egs.data as sheet_data, egs.revision_id from evaluation_grades_sheetsi egs where egs.task_id = :task_id and content_revision__is_live(egs.grades_sheet_id) = true $orderby