SELECT CONCAT(DATE_FORMAT(CURRENT_DATE, '%Y'), LPAD(CAST(IFNULL(MAX(SUBSTRING(STTS_HSTRY_ID,5)) + 1, 1) AS INT), 16, '0')) AS NEW_ID FROM TB_CRDN_STTS_HSTRY
SELECT CONCAT(DATE_FORMAT(CURRENT_DATE, '%Y'), LPAD(CAST(IFNULL(MAX(SUBSTRING(STTS_HSTRY_ID, 5)) + 1, 1) AS INT), 16, '0')) AS NEW_ID
FROM TB_CRDN_STTS_HSTRY
WHERE STTS_HSTRY_ID LIKE CONCAT(DATE_FORMAT(CURRENT_DATE, '%Y'), '%')