Amazon Interview Question

ID table with duplicate rows: id1,id2 Select only the duplicate rows.

Interview Answers

Anonymous

Apr 15, 2021

SELECT ID FROM MyTable GROUP BY ID HAVING COUNT(ID) > 1

13

Anonymous

Aug 17, 2021

with cte as (select id, row_number() over (partition by id order by id asc ) as "Rn" from tab1) select id from tab1 where Rn > 1

1