Query to find contact associated in Sub-accounts

Query to find contact associated in Sub-accounts

SELECT org.NAME "Account Name",aaauser.FIRST_NAME "Contact Name",ucinfo.EMAILID "Contact Email", au1.first_name "Subaccount Contact's name", aci.emailid "Subaccount's contact's email address" FROM AaaUser aaauser LEFT JOIN AaaUserContactInfo user_contact ON aaauser.USER_ID=user_contact.USER_ID LEFT JOIN AaaContactInfo ucinfo ON user_contact.CONTACTINFO_ID=ucinfo.CONTACTINFO_ID LEFT JOIN SDUser sduser ON aaauser.USER_ID=sduser.USERID LEFT JOIN Customer_Requester custreq ON sduser.USERID=custreq.REQUESTER_ID LEFT JOIN Customer cust ON custreq.CUSTOMER_ID=cust.CUSTOMER_ID LEFT JOIN AaaOrganization org ON cust.CUSTOMER_ID=org.ORG_ID LEFT JOIN Customer_Product cust_prd ON cust.CUSTOMER_ID=cust_prd.CUSTOMER_ID LEFT JOIN ComponentDefinition prd ON cust_prd.PRODUCT_ID=prd.COMPONENTID LEFT JOIN ComponentType prdType ON prd.COMPONENTTYPEID=prdType.COMPONENTTYPEID LEFT JOIN Department_Account dep_acc ON cust.CUSTOMER_ID=dep_acc.ACCOUNTID LEFT JOIN Customer_Fields account_udf ON dep_acc.DEPARTMENT_ACCOUNTID=account_udf.DEPARTMENT_ACCOUNTID LEFT JOIN DepartmentUser dep_user ON sduser.USERID=dep_user.USERID LEFT JOIN subaccount sac on org.org_id=sac.parentaccountid left join customer_requester cr on sac.subaccountid=cr.customer_id left join aaauser au1 on cr.requester_id=au1.user_id left join aaausercontactinfo auci on au1.user_id=auci.user_id left join aaacontactinfo aci on auci.contactinfo_id=aci.contactinfo_id WHERE (((((aaauser.DESCRIPTION LIKE '%Hosted%') AND (account_udf.UDF_CHAR1 = 'Active')) AND (prdType.COMPONENTTYPENAME = 'Hosted')) AND (prd.COMPONENTNAME = 'SMSC')) AND ((((dep_user.DEPARTMENTID = 1) AND ( dep_user.USERTYPE = 'Contact')) AND ((prd.DEPARTMENTID = 1) OR (prd.DEPARTMENTID IS NULL))) AND ((dep_acc.DEPARTMENTID = 1) OR (dep_acc.DEPARTMENTID IS NULL)))) AND (sduser.STATUS='ACTIVE') ORDER BY 1
          • Related Articles

          • Query to find Contact roles

            All requests from their account and sub account  SELECT aaauser.FIRST_NAME "Contact Name",org.NAME "Account Name",ucinfo.EMAILID "Contact Email",ucinfo.LANDLINE "Contact Phone",ucinfo.MOBILE "Contact Mobile",ucinfo.FAX "Contact Fax" FROM AaaUser ...
          • Steps to Import accounts / contacts through schedule csv from SCP 11001 build

            This is applicable only from 11001 builds. How to do? # Based on the Globalconfig table entry with category as 'CSVUserImportSchedule', this can be turned ON/OFF. By default this is turned OFF.  Query to enable the feature - update Globalconfig set ...
          • Query to find the last logged time of a contact in the portal

            select aas.session_id "SessionID", aal.name "User Name",aau.FIRST_NAME "Contact Name",org.NAME "Account Name", parentorg.NAME "Parent Account Name",suborg.name "Sub Account", aas.user_host "User Host", aas.application_host "Application Host", ...
          • List of contacts logged into the system

            Mysql select aas.session_id "SessionID", aal.name "User Name",aau.FIRST_NAME "Contact Name",org.NAME "Account Name", aas.user_host "User Host", aas.application_host "Application Host", longtodate(aas.opentime) "Start Time", longtodate(aas.closetime) ...
          • Query to show list of contacts that are assigned to an account but not have a login

            The below query shows the list of contacts that are assigned to an account, but does not have a login.  SELECT org.NAME AS "Account Name" ,aaauser.FIRST_NAME AS " Contact with no login" FROM AaaUser aaauser LEFT JOIN AaaUserContactInfo user_contact ...