Tags
Anonymous Giver Account Cleanup
Delete any saved accounts from Anonymous Giver that are also associated with another person.
Query
DELETE
FROM [FinancialPersonBankAccount]
WHERE
[AccountNumberSecured] IN (
--Acccounts that have more than 1 person assocciated...
SELECT [AccountNumberSecured]
FROM [FinancialPersonBankAccount]
GROUP BY [AccountNumberSecured]
HAVING COUNT(1) > 1
)
AND [PersonAliasId] IN (
--...and one of those people is anonymous giver
SELECT [Id]
FROM [PersonAlias]
WHERE [PersonId] = 2
)