SQL Delete duplicate rows based on column I need to remove the duplication of rows based on column to have unique data in this column, additionally I need another condition when the value equal specific information.

In my example I want to filter by TagName to avoid duplication plus I need the value of Alarmstate = 'UNACK_ALM'.

Please refer to the pictures for more clarification, I did it using Excel but I need to write it in SQL view.

Thanks for coopearation.
To remove duplicate rows, use a CTE and partition using the data you want to check for duplicates to assign a row_number against. Then remove any where the row_number > 1 (removing multiple duplicates)

    --REMOVE DUPLICATES
    WITH CTE AS
    (SELECT ROW_NUMBER() OVER 
(PARTITION BY column_tocheck_duplication_against ORDER BY ( SELECT 0)) RN
    FROM TableName)
    DELETE FROM CTE WHERE RN &gt; 1