Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


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



I want to make a query where I want to eliminate the duplicate rows from the table. For example :..

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

I want to make a query where I want to eliminate the duplicate rows from the table. For example :..

Answer / supriya

You want to delete the rows permanently or what

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More MySQL Interview Questions

What is a data directory?

0 Answers  


How MySQL Optimizes DISTINCT?

0 Answers  


Is null in mysql?

0 Answers  


Where is the mysql config file?

0 Answers  


maximum database size of mysql database

2 Answers  






Is mysql a server?

0 Answers  


What is required to create mysql database?

0 Answers  


What are the different tables present in MySQL?

0 Answers  


how can you test for null values in a database? : Mysql dba

0 Answers  


How can you validate emails using a single query?

0 Answers  


How do I stop a mysql service?

0 Answers  


What could be the reason that the mysql statement 'select avg (salary) from emp' generates an inaccurate output?

0 Answers  






Categories