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 |
Is mysql running ubuntu?
What is heap table in mysql?
What?s the default port for MySQL Server?
What is difference between mysql and mariadb?
What is trigger in mysql?
For the database from the previous question, please give an SQL query which returns the invoice number of all invoices which contain the article with the number ?1234?. The query should be able to run under a MySQL 4.0 database.
What are the different table present in MYsql?
What is meant by sharding?
Can I use mariadb instead of mysql?
how to take mysql database backup?
What is dirty read and phantom read?
What is mysql ndb?