I have a DB table that has a member ID field and a level field...

There can be duplicate member IDs because they can have multiple steps

There can be duplicate step numbers because multiple members can be on the same step

But there should NEVER be a duplicate combination of memberID and Step...

It was brought to my attention today through a support person that there are instances where this is true though...

While I know I need to figure out what is causing it, I first need to determine how many cases of this there are, so I can use that info to help track down the issue.

What I don't know, is how to write a query that will pull out only the records that have duplicate combinations of the memberID and the Step, without listing the entire table with several thousand records...

Could someone help me out with how this query should be structured?

Thanks in advance.


Member Avatar
SELECT member_id, level, count(level) FROM steps GROUP BY member_id,level HAVING COUNT(level) > 1

Thank you ardav,

I appreciate your response, and assuming that it was correct, there were no other instances of the issue. I did a manual scan of the file as well, and didn't see any duplicates, although those would be extremely easy to miss.

And I also believe I found the source of the issue, so all should be well.

thanks again.


Member Avatar

Are we solved?