DB Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ranked_manuals AS ( SELECT e.*, pe.locale AS p_locale, SUBSTRING_INDEX(e.file, '' at line 1 WITH ranked_manuals AS ( SELECT e.*, pe.locale AS p_locale, SUBSTRING_INDEX(e.file, '/', -1) AS file_name, ROW_NUMBER() OVER ( PARTITION BY SUBSTRING_INDEX(e.file, '/', -1) ORDER BY CASE WHEN pe.locale = 'global/en' THEN 0 ELSE 1 END, e.release_date DESC, e.name ) AS row_num FROM product_entities AS pe JOIN manuals AS e ON (pe.domain = e.domain AND pe.entity_id = e.id AND e.deleted = 0) WHERE pe.domain='public' AND pe.product_id=1135 AND pe.locale IN ('global/en', 'cn/zh') AND pe.entity_type='manual' AND e.id NOT IN (9538, 9765) ) SELECT * FROM ranked_manuals WHERE row_num = 1 ORDER BY CASE WHEN p_locale = 'global/en' THEN 0 ELSE 1 END, release_date DESC, name If problem persists, please contact the system administrator.