if 3 duplicate records in a table,i want to delete 2 duplicate
records by keeping 1 as it is,how?
Answer Posted / venkat
if u r table like this
sno sname fee
1 a 1000
1 a 1000
2 b 1000
2 b 1000
3 c 1000
3 c 1000
--- write this
with duplicatecte
as
(select row_number()over(partition by sno,sname order by fee
)as rnum from students )
delete from dupcte where rnum>1
---run this query
select * from students
--out put is
1 a 1000
2 b 1000
3 c 1000
this is correct
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
what is database replicaion? : Sql server database administration
What are the new features introduced in SQL Server 2000 (or the latest release of SQL Server at the time of your interview)? What changed between the previous version of SQL Server and the current version?
Can a trigger be created on a view?
Explain primary key in sql server?
What is a data collection table?
How to fetch the next row from a cursor with a "fetch" statement?
What are the new data types are introduced in sql 2000?
How to connect to a sql server using odbc_connect()?
How can you find out how many rows returned in a cursor?
tell me what are the steps you will take to improve performance of a poor performing query? : Sql server database administration
How to list all login names on the ms sql server?
what is the sql equivaent of the dataset relation object ?
what is dbcc? : Sql server database administration
Mention the command used to rename the database.
Explain some stored procedure creating best practices or guidelines?