, , 0, 1. :
SELECT id
FROM (
SELECT id, count(*) as cnt, max(group) as mx, min(group) as mn
FROM myTable
GROUP BY group
) A
WHERE NOT mx = cnt - 1
AND NOT mn = 0
Hope this helps. This is probably not the cleanest or the most efficient, but hope this helps.
EDIT: Actually, reviewing the answer before mine and thinking about HAVING, it would probably be as clean as this.
SELECT ID
FROM myTable
GROUP BY ID
HAVING MAX(group) >= COUNT(DISTINCT group)
source
share