
시나리오 지금까지 이력성으로 관리하던 데이터를 단 하나의 레코드씩만 관리 예전에 있던 복수의 레코드는 가장 최신의 데이터1건만 이관 부모키로 판단되는 기준값이 있고 CREATE_TIME / UPDATE_TIME의 최신데이터 분별필드도 존재함 select t1.id, t1.create_time, t1.txt from table t1, (select id, max(create_time) as max_time from table where del_flg = 0 and txt '' and txt is not null group by id having count(id) > 1) t2 where t1.create_time = t2.max_time and t1.id = t2.id and t1.del_flg = 0 and t1.txt '' and t1 is not null 이해안되면 그냥 외우자!...
#group_by
#having
#mysql
#데이터이관
#데이터이행
원문링크 : group by에서 가장 최신데이터만 선택