I want to make a query where I want to eliminate the
duplicate rows from the table.
For example :
Input : Table : NAME
Column1 Column2
India USA
USA India
UK India
India UK
The desired output that I want to eliminate the duplicates
Output
India USA
UK India
Thanks
Answers were Sorted based on User's Feedback
Answer / bramhendra kumar
CREATE TABLE #TBLD (NAME VARCHAR(20),NAME2 VARCHAR(20))
INSERT INTO #TBLD VALUES('India','USA'),('USA','India'),('UK', 'INDIA'),('India','UK')
WITH CTE
AS
(
SELECT *, ROW_NUMBER() OVER (PARTITION BY NAME ORDER BY NAME) AS ROWNUM1,
ROW_NUMBER() OVER (PARTITION BY NAME2 ORDER BY NAME2) AS ROWNUM2
FROM #TBLD
)
DELETE FROM CTE WHERE ROWNUM1>1 OR ROWNUM2>1
SELECT * FROM #TBLD
TRUNCATE TABLE #TBLD
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / supriya
You want to delete the rows permanently or what
| Is This Answer Correct ? | 0 Yes | 1 No |
How do I copy a table in mysql?
What is row level locking?
How do I save in mysql?
How will show all records containing the name "sonia" and the phone number '9876543210'
what is the querry for all managers salary?
What is a query in mysql?
Why MySQL is used?
How to see the create table statement of an existing table?
Is mysql free for enterprise?
What is meant by sharding?
Can not connect to mysql server 10060?
What are the differences between mysql vs sql server?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)