So I have a table that looks like this
ID AccountType Name Individ
1 O Acme Company 00
2 P Joe Smith 00
1 John Doe 01
1 Steve Johnson 02
3 P Shirley Johnson 00
2 Jane Smith 01
1 Kevin Lastname 03
So, O stands for Organization, and P stands for personal. Subaccounts are mixed in the table with the primary accounts, and a subaccount of an account has the same ID, but a null accounttype. I need to find a way to find all subaccounts of one AccountType, excluding subaccounts of personal accounts. I tried an INNER JOIN, but I can't join a column on itself.
SELECT * FROM <schema.table>
INNER JOIN <schema.table> ON table.id = table.id
WHERE accounttype = ('B' OR 'F' OR 'O' OR 'S') AND
individ != '0'
GROUP BY 'id';