Just another way to do this with a simple self join.
Scheme:
CREATE TABLE #TAB (ID INT, CustomerID INT, AccountNumber VARCHAR(20), StatusID INT) INSERT INTO #TAB SELECT 1,300,300100, 1 UNION ALL SELECT 2,300,300200, 3 UNION ALL SELECT 3,300,300300, 3 UNION ALL SELECT 4,400,400100, 1 UNION ALL SELECT 5,400,400200, 1 UNION ALL SELECT 6,500,500100, 1
And do a Self Join, as shown below, and filter out the Where clause, which has pending status records.
SELECT AP.* FROM
source share