sql - Delete duplicate entries keeping one entry of each if id column not available -


i have tried,

delete student firstname in (     select firstname      (      select firstname,      row_number() over(partition firstname order firstname) rn      student     ) student     rn > 1 ); 

but deleting both duplicate records. please correct query. in advance.

you can use cte

    mycte          (        select [firstname], row_number() over(partition firstname order firstname) rn        student     )     delete mycte rn > 1;     select * students; 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -