Get ID which has two rows with specific values for one column
WITH cte AS ( SELECT id, type, COUNT(DISTINCT type) OVER (PARTITION BY id) cnt
              FROM table
              WHERE type IN ('A', 'B')
            )
SELECT id, type
FROM cte
WHERE cnt = 2