Search
 
SCRIPT & CODE EXAMPLE
 

SQL

delete dublicate rows sql

WITH CTE AS(
   SELECT [col1], [col2], [col3], [col4], [col5], [col6], [col7],
       RN = ROW_NUMBER()OVER(PARTITION BY col1 ORDER BY col1)
   FROM dbo.Table1
)
DELETE FROM CTE WHERE RN > 1
Comment

sql delete duplicate rows

WITH cte AS (
    SELECT 
        contact_id, 
        first_name, 
        last_name, 
        email, 
        ROW_NUMBER() OVER (
            PARTITION BY 
                first_name, 
                last_name, 
                email
            ORDER BY 
                first_name, 
                last_name, 
                email
        ) row_num
     FROM 
        sales.contacts
)
DELETE FROM cte
WHERE row_num > 1;
Comment

DELETE DUPLICATE VALUES FROM A TABLE IN SQL SERVER

WITH cte AS (
    SELECT 
        contact_id, 
        first_name, 
        last_name, 
        email, 
        ROW_NUMBER() OVER (
            PARTITION BY 
                first_name, 
                last_name, 
                email
            ORDER BY 
                first_name, 
                last_name, 
                email
        ) row_num
     FROM 
        sales.contacts
)
DELETE FROM cte
WHERE row_num > 1;
Code language: SQL (Structured Query Language) (sql)
Comment

delete duplicate sql

WITH CTE AS(
   SELECT [col1]
           ,[col2]
           ,[col3]
     ,
       RN = ROW_NUMBER()OVER(PARTITION BY [col1],[col2],[col3] ORDER BY [col1],[col2],[col3])
   FROM [dbo].[table1]

)
DELETE FROM CTE WHERE RN > 1
Comment

PREVIOUS NEXT
Code Example
Sql :: sql server query all database objects 
Sql :: update field sql 
Sql :: drop index oracle 
Sql :: 2nd highest salary in mysql 
Sql :: sql get last id 
Sql :: postgresql cast 
Sql :: sql show all users 
Sql :: change default schema sql server 
Sql :: how to check if a row is null in sql 
Sql :: brew install mysql 8 
Sql :: how to rename a database in tsql 
Sql :: SHOW COLUMNS Statement 
Sql :: mysql select multiple rows into one column 
Sql :: count characters of string mysql 
Sql :: mysql alter table add column first 
Sql :: mariadb alter table add column if not exists example 
Sql :: mysql update column default value CURRENT_TIMESTAMP error 
Sql :: How do I modify a MySQL column to allow NULL? 
Sql :: mysql change password 
Sql :: row number mssql 
Sql :: sql server output parameter 
Sql :: mysql remove html tag 
Sql :: oracle pagination query rownum 
Sql :: mysql query dates between two dates 
Sql :: sql current date 
Sql :: temp table vs variable table in sql server 
Sql :: sql all columns 
Sql :: sql server case sensitive search 
Sql :: how to find the number of rows updated in oracle pl/sql 
Sql :: mysql trim spaces 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =