In my table I need to know if each ID has one and only one ID_name. How can I write such query?
I tried:
select ID, count(distinct ID_name) as count_name
from table
group by ID
having count_name > 1
But it takes forever to run.
Any thoughts?
or
Now, most
IDcolumns are defined asprimary keyand are unique. So in a regular database you’d expect both queries to return an empty set.