A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
This query may work for you, although the result does not match our expected exactly. On the other hand, I am not sure your output is consistent.
SELECT 'P&B Match' AS text, a.portfolio, a.bin
FROM test_all_accounts a
WHERE EXISTS (SELECT *
FROM test_client_subset c
WHERE a.portfolio = c.portfolio
AND a.bin = c.bin)
UNION ALL
SELECT 'Accounts port match' AS text, a.portfolio, a.bin
FROM test_all_accounts a
WHERE EXISTS (SELECT *
FROM test_client_subset c
WHERE a.portfolio = c.portfolio)
AND NOT EXISTS (SELECT *
FROM test_client_subset c
WHERE a.portfolio = c.portfolio
AND a.bin = c.bin)
UNION ALL
SELECT 'Client port match' AS text, c.portfolio, c.bin
FROM test_client_subset c
WHERE EXISTS (SELECT *
FROM test_all_accounts a
WHERE a.portfolio = c.portfolio)
AND NOT EXISTS (SELECT *
FROM test_all_accounts a
WHERE a.portfolio = c.portfolio
AND a.bin = c.bin)
UNION ALL
SELECT 'Accounts P&B NOT match' AS text, a.portfolio, a.bin
FROM test_all_accounts a
WHERE NOT EXISTS (SELECT *
FROM test_client_subset c
WHERE a.portfolio = c.portfolio)
UNION ALL
SELECT 'Client P&B not match' AS text, c.portfolio, c.bin
FROM test_client_subset c
WHERE NOT EXISTS (SELECT *
FROM test_all_accounts a
WHERE a.portfolio = c.portfolio)
ORDER BY portfolio, bin