Created
May 2, 2017 13:11
-
-
Save matthewpoer/58e9f348fc244ecf40e4de926a3f3668 to your computer and use it in GitHub Desktop.
Select the Account ID, Name and Parent ID and Name for all Sugar Accounts with Parents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select | |
accounts.id as account_guid, | |
accounts.name as account_name, | |
accounts.parent_id as parent_account_guid, | |
parents.name as parent_account_name | |
from accounts | |
join accounts parents | |
on parents.deleted = 0 | |
and accounts.parent_id = parents.id | |
where accounts.deleted = 0 | |
and accounts.parent_id is not null | |
and accounts.parent_id <> '' | |
order by parent_account_name asc; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment