Query to display Accounts and Sub Accounts (8.1)

Query to display Accounts and Sub Accounts (8.1)

Execute the below query from the Reports Tab -> New Query (Applicable for 8.1 version)


SELECT acc.NAME AS "Account",sorg.NAME AS "Sub Account" FROM Customer cust 
LEFT JOIN AaaOrganization acc ON cust.CUSTOMER_ID=acc.ORG_ID 
LEFT JOIN SubAccount subacc on cust.CUSTOMER_ID=subacc.parentaccountid 
LEFT JOIN AaaOrganization sorg ON subacc.subaccountid=sorg.ORG_ID
LEFT JOIN Department_Account dep_acc ON cust.CUSTOMER_ID=dep_acc.ACCOUNTID 
WHERE  (cust.customer_id not in (select subaccountid  from SubAccount) and dep_acc.DEPARTMENTID = 1) order by acc.NAME, sorg.NAME

                  New to ADSelfService Plus?