Skip to content
Advertisement

Select two duplicate records if it has 3 duplicate records

Is there a way to get only two duplicate records in SQL Server if it has three duplicate records? Example I have records ’10/13/2020′, ’10/13/2020, ’10/13/2020′. as you can see, it has 3 duplicate records. What I want is I will select only two duplicate records. if it has count 4, and 5 and above, still 2 counts will get

Current output:

I want only to retrieve two counts, is that possible?

Advertisement

Answer

Perhaps something like this using the window functions

Example

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement