oracle - Query for delete -
i have employee table in database have 2 column employee_card , ledger_month. employee can have relation multiple ledger month. want keep employee highest ledger month , rest deleted.
input: employee_card ledger_month 1 111112 1 111114 2 111112 2 111114 output : employee_card ledger_month 1 111114 2 111114
i tried query
delete v2titas.employee_copy_upgraded card not in(select card,max(ledger_month) v2titas.employee_copy_upgraded group card) or ledger_month not in (select card,max(ledger_month) v2titas.employee_copy_upgraded group card)
but showing error "too many value". how can this?
delete v2titas.employee_copy_upgraded et exists ( select * v2titas.employee_copy_upgraded et.card = it.card , et.ledger_month < it.ledger_month );
Comments
Post a Comment