SELECT * FROM (
        SELECT *,TIMESTAMPDIFF(month, registration_date, NOW())  as dis,
        CASE WHEN registration_date   <![CDATA[ <= ]]>  DATE_SUB(NOW(), INTERVAL 8 YEAR) AND audit =1 THEN 1 ELSE 2 END AS sort_order
        FROM care_record ${ew.customSqlSegment} ) AS subquery ORDER BY sort_order, registration_date DESC, create_time desc