delete from kjt_pay
where ORDERNO in (
select T3.ORDERNO
from (select
T.ORDERNO,
count(1)
from kjt_pay T
group by T.ORDERNO
having count(1) > 1) T3
) and GUID not in (select T4.max_id
from (
select
max(T5.GUID) max_id,
count(1)
from kjt_pay T5
group by T5.ORDERNO
having count(1) > 1
) T4);