<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "mybatis-3-mapper.dtd">
<mapper namespace="com.mortals.xhx.module.attendance.dao.ibatis.AttendanceRecordDaoImpl">
    <delete id="delete-duplicate-record">
        DELETE
        FROM
        mortals_xhx_attendance_record
        WHERE
        id IN (
        SELECT a.id FROM (SELECT
        id
        FROM
        mortals_xhx_attendance_record
        GROUP BY
        staffId,
        DATE_FORMAT( attendanceDate, '%y-%m-%d' )
        HAVING
        count( staffId ) > 1
        ORDER BY
        attendanceDate) AS a 	)
    </delete>
</mapper>