delete duplicate records ....
need to delete duplicate from the table.emp_id is the primary key...but duplicate records have been inserted in the table dur to bad logic.but to make it simple i can identify all records that have same demographic_id as duplicates.I need to delete all the duplicates and keep only those have been last updated(i mean record that have max(last_update).
the rows are as follows.the query should delete all the below record accept one with emp_id as 4 and 8 as the have max date in thier respective groups.
emp_id demog_id name last_update
1 23 ash 1/1/2006
2 23 ashu 1/5/2007
3 23 ashly 1/1/2004
4 23 ashyun 11/12/2007
5 87 jay 1/1/2005
6 87 jayesh 1/5/2002
7 87 jashy 1/1/2000
8 87 jai 11/12/2007
thanks in advance