SELECT
    DECODE(MAX(group_cd),NULL,'0001',LPAD(MAX(group_cd)+1,4,'0')) group_cd
FROM
    table


 SELECT
    DECODE(MAX('0001'),NULL,'0001',LPAD(MAX('001')+1,5,'0')) group_cd
FROM
    dual;


+ Recent posts