How to sql select a product with two status?

database, sql, sql-server, t-sql

Solution

To select Products with both status (1,2):

Sql-Server fiddle demo

SELECT ProductId 
FROM products
WHERE status IN (1, 2)
GROUP BY ProductId
HAVING COUNT(distinct status) = 2

Problem

I have a `Products` table with `ProductId` and `StatusId` columns How can i select all the products which have `StatusId` 1 and 2 (two rows) ?

Original source