Doing a query where I am trying to differentiate between accounts with Sites that have a Status of "ND" only, not Sites with both "ND" and "D".
Table:
AccountID -- Site -- Status
ABC -- 1 -- D
ABC -- 2 -- ND
123 -- 1 -- ND
So my query should only show 123 because ABC had both.
Right now I have a query that pulls all Accounts that has both "D" & "ND" and can do a query that one pulls either but can't work out how to only pull ones that have only "ND" and no "D". Accounts can have over 100 sites.
If someone can point me in the right direction, thanks
Here is my code for pulling accounts that have both
Code:SELECT DISTINCT AccountID, "PND" AS AdjStatus FROM table WHERE Status = "D" AND AccountID IN (SELECT AccountID FROM table WHERE Status = "ND");