• First, why do you use those values in the HAVING clause instead of the WHERE clause?

    Also, it's not really clear what's not working. If you get extra rows, then you need to determine what criteria they're satisfying in the query. From the query, we can't tell you what data is being returned or not being returned. There's no way to tell.

    Also, WHERE isn't an sentence. A sentence is a grammatical contruct, not a part of T-SQL. There's a WHERE clause.