There is a table T1, which contains records with the same value of one field F1 (we will call such records duplicates). To find out how many such duplicates I write a query:
The table also has a numeric field F2. Task: remove all duplicates from the table, leaving only those with the smallest F2 among its group. In this case, among the smallest there may be more than one record. In this case, you must leave any.
I found an example on this resource, however it doesn't work. An error occurs during execution: "Token ( was not valid. Valids tokens: <IDENTIFIERS>". Why does the error occur?
Code:
select F1, count(*) CNT from T1 group by F1 having count(*) > 1
I found an example on this resource, however it doesn't work. An error occurs during execution: "Token ( was not valid. Valids tokens: <IDENTIFIERS>". Why does the error occur?
Code:
delete from (select rownumber() over(partition by F1 order by F1, F2) from T1) AS E(RN) where RN> 1
Comment