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
How will you find out if there are expensive SQL statements running or not?
Explain four layers of abstraction microsoft architectured?
Define indexes?
How do you Implement SSIS Packages in your Project?
If a user does not have permission to a table, but has permission to a view created on it, will he be able to view the data in table?
What is subquery in sql?
what types of replication are supported in sql server? : Sql server database administration
Explain the flow of creating a cube? : sql server analysis services, ssas
How to perform key word search in tables?
Which is faster statement or preparedstatement?
What is lookup override?
How can I check if a view exists in a sql server database?
How to check table values in sql server?
How to define and use table alias names in ms sql server?
Can we do dml on views?