 |
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

March 5th, 2005, 01:16 PM
|
Authorized User
|
|
Join Date: Oct 2004
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
How to delete repeated records in a query
Hi,
My question is :
Table1:
Eid Ename
1 a
1 a
1 a
2 b
2 b
How to remove the repeated rows after deletion .
Ramkumar
A.D.Ramkumar
__________________
Ramkumar A D
|

March 6th, 2005, 01:45 AM
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
Is you question that you want to remove duplicate rows?
|

March 7th, 2005, 01:05 AM
|
Authorized User
|
|
Join Date: Feb 2005
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Executed following statement in sequence:
Select distinct * into #tmpTable from Table1
Truncate Table Table1
Insert Into Table1 Select * from #tmpTable
Drop Table #tmpTable
Go
Cheers,
Pooja Falor
|

March 7th, 2005, 11:23 AM
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
if you wanted to remove duplicate rows
SELECT Eid, Ename
FROM myTable
Group By Eid,Ename
Having Count(*) >1
|

March 10th, 2005, 12:09 PM
|
Authorized User
|
|
Join Date: Oct 2004
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Need a Single DELETE query to this
Ramkumar
A.D.Ramkumar
|

March 10th, 2005, 04:10 PM
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
DELETE
FROM MyTable
WHERE EID IN (SELECT EID FROM MyTable Group By EID,Ename Having Count(EID) > 1);
|

March 12th, 2005, 11:09 AM
|
Authorized User
|
|
Join Date: Oct 2004
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Sacchi,
Sorry, query didn't work perfectly.
I need an output after deleting repeated data.
Ramkumar
A.D.Ramkumar
|

March 12th, 2005, 01:35 PM
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ramkumar, please provide us with a sample output
how you like your SQL to retrun your query output
|

March 13th, 2005, 11:45 AM
|
Authorized User
|
|
Join Date: Oct 2004
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi,
output should be:
Eid Ename
1 a
2 b
Expecting your answer.
Ramkumar
A.D.Ramkumar
|

March 13th, 2005, 02:44 PM
|
Friend of Wrox
|
|
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Are you using SQL server or Access?
|
|
 |