|
Delete Duplicated Rows in one query, simple and easy
|
Email
|
| Submitted on: |
4/4/2005 6:02:54 PM |
| By: |
mid.net
|
| Level: |
Intermediate |
| User Rating: |
By 5 Users |
| Compatibility: |
SQL Server 2000, SQL Server 7.0, SQL Server 6.5 and earlier, Other |
| Views: |
12563 |
|
(About the author) |
|
|
|
Delete duplicated Rows width have an Identity (unique) Column
|
| |
Terms of Agreement:
By using this article, you agree to the following terms...
- You may use
this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
- You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
- You may link to this article from another website, but ONLY if it is not wrapped in a frame.
- You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
|
Table Original
| Id |
Descript |
| 1 |
aa |
| 2 |
aa |
| 3 |
bb |
| 4 |
cc |
| 5 |
dd |
| 6 |
dd |
| 7 |
ee |
I want to delete all Duplicated by 'Descrip'
Delete from mitable where id Not In
(Select top 1 id from mitable as MR1 where
MR1.descrip=mitable.descrip)
|
Id |
Descript |
| 1 |
aa |
| 3 |
bb |
| 4 |
cc |
| 5 |
dd |
| 7 |
ee |
All Dupplicated Data Removed enjoy that
|
|
Other 1 submission(s) by this author
|
|
Report Bad Submission
|
Your Vote
|
| |
Other User Comments
|
4/5/2005 4:30:10 AM: dsoftnet
How you will be identifying which row wil get deleted, assum you have one table containing name as (If this comment was disrespectful, please report it.)
|
4/5/2005 7:27:57 AM: mid.net
the "delete" query remove all duplicated item without any other information than the table which contains the duplicated rows, try the query and you see which I tell you (If this comment was disrespectful, please report it.)
|
7/4/2005 5:15:57 AM:
it is very good (If this comment was disrespectful, please report it.)
|
1/30/2007 12:40:01 AM: kaja
display the first 5 maximum salary for each department (If this comment was disrespectful, please report it.)
|
Add Your Feedback
Your feedback will be posted below and an email sent to
the author. Please remember that the author was kind enough to
share this with you, so any criticisms must be stated politely, or they
will be deleted. (For feedback not related to this particular article, please
click here instead.)
To post feedback, first please login.
|