I have two tables called game and gameprogress. Gameprogress has a column called state that describes progress. Game is related to gameprogress trough an id.
Possible states is: 1,3,4 in gameprogress.
I want to find games without a state = 1 and without a state = 4. I've tried something like this:
select top 10 gp.gameid, count(gp.state) as dup
from gameprogress gp
join game g on g.id= gp.gameid
where g.gamestate != 2 and gp.state != 1
group by gp.gameid
having count(gp.state)>1