select file_name, file_type, file_desc, path, notes, sequence from images where sub_type = '4' and is_web_enabled='t' and active = 't' and (sub_code = '0280158298') order by file_type, cast(notes as varchar(2000)) desc : Type mismatch