SELECT DISTINCTROW `mantis_bug_table` . * , CASE WHEN `NULLIF` ( `cf_alias_13` . `value` , ? ) IS NULL THEN ? ELSE ? END AS `cf_sortfield_13_null` , CAST ( `NULLIF` ( `cf_alias_13` . `value` , ? ) AS DECIMAL ) AS `cf_sortfield_13` , CASE WHEN `NULLIF` ( `cf_alias_17` . `value` , ? ) IS NULL THEN ? ELSE ? END AS `cf_sortfield_17_null` , CAST ( `NULLIF` ( `cf_alias_17` . `value` , ? ) AS DECIMAL ) AS `cf_sortfield_17` FROM `mantis_bug_table` JOIN `mantis_project_table` ON `mantis_project_table` . `id` = `mantis_bug_table` . `project_id` LEFT JOIN `mantis_bugnote_table` `visible_bugnote` ON `mantis_bug_table` . `id` = `visible_bugnote` . `bug_id` AND ( `visible_bugnote` . `view_state` = ? OR `visible_bugnote` . `reporter_id` = ? ) JOIN `mantis_bug_text_table` ON `mantis_bug_table` . `bug_text_id` = `mantis_bug_text_table` . `id` LEFT JOIN `mantis_bugnote_text_table` ON `visible_bugnote` . `bugnote_text_id` = `mantis_bugnote_text_table` . `id` LEFT OUTER JOIN `mantis_custom_field_string_table` `cf_alias_13` ON `mantis_bug_table` . `id` = `cf_alias_13` . `bug_id` AND 