
update sb_person_grade set newest = false;

create table v_sb_person_grade_bk as select * from (
SELECT id from sb_person_grade
where
	   active =true
	AND id IN (
    SELECT
      SUBSTRING_INDEX(GROUP_CONCAT(tt.id ORDER BY tt.create_time DESC),',',1)
    FROM
      sb_person_grade tt
    WHERE
      tt.active = TRUE
    GROUP BY
      tt.personId
  )
)tt;

update sb_person_grade t1
set newest = true
	where
	  t1.active =true
	AND t1.id IN (
SELECT id from v_sb_person_grade_bk
);





