I'd like to do a query for every GroupID (which always come in pairs) in which both entries have a value of 1 for HasData.

|GroupID | HasData |
|--------|---------|
|  1     |  1      |
|  1     |  1      |
|  2     |  0      |
|  2     |  1      |
|  3     |  0      |
|  3     |  0      |
|  4     |  1      |
|  4     |  1      |

So the result would be:

1
4

here's what I'm trying, but I can't seem to get it right. Whenever I do a GROUP BY on the GroupID then I only have access to that in the selector

<!-- language: lang-sql -->
SELECT GroupID
FROM Table
GROUP BY GroupID, HasData
HAVING SUM(HasData) = 2 

But I get the following error message because HasData is acutally a bit:

Operand data type bit is invalid for sum operator.

Can I do a count of two where both records are true?

just exclude those group ID's that have a record where HasData = 0.

select distinct a.groupID
from table1 a 
where not exists(select * from table1 b where b.HasData = 0 and b.groupID = a.groupID)