SELECT DISTINCTROW CAST ( `NULLIF` ( `cfst` . `value` , ? ) AS DECIMAL ) AS `cast_value` FROM `mantis_custom_field_string_table` `cfst` WHERE `cfst` . `field_id` = ? AND `cfst` . `bug_id` IN ( SELECT `mantis_bug_table` . `id` FROM `mantis_bug_table` JOIN `mantis_project_table` ON `mantis_project_table` . `id` = `mantis_bug_table` . `project_id` WHERE `mantis_project_table` . `enabled` = ? AND ( `mantis_bug_table` . `project_id` IN (...) ) ) ORDER BY `cast_value` 