I have the following table student which allows duplicate id's as shown below:
Now in this table I need to delete all other duplicate record and leaving any one of the unique record of the id.
i.e for example if execute the delete statement 7 records should be deleted leaving 2 records one with id as '1' and another with id as '2'.
As shown in below diagram:-
[Final Expected output][2]
How can i write a single SQL query to get above result.
Below is the sample sql query I am trying which is throwing compile time error in sql editor as "unexpected student identifier".
DELETE FROM student as a
WHERE a.sno not in(select b.sno from test.student as b group by b.id);
Kindly help me to figure out my mistake in query.
thanks in advance.