Skip to content
Advertisement

Return data when not all values in column are equal

I have a simple table which looks like this:

How can I construct a query that will return the ids that do not have the same count for each name? So using the above data, id 2 would be returned as not all name counts are equal.

It would be great if it’s possible without hardcoding each name individually as there are a lot in the real dataset.

Advertisement

Answer

A simple method is aggregation:

If you want to be sure there are three rows, then add and count(*) = 3.

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