Query to get technician details(domain, associated account, email) from builds (MSSQL & PGSQL)

Query to get technician details(domain, associated account, email) from builds (MSSQL & PGSQL)

Tested in builds from PGSQL (14300) or MSSQL (14306)

SELECT 
  aau.first_name "First Name", 
  sdu.lastname "Last Name", 
  AaaContactInfo.EMAILID "Email Address", 
  sdo.name "Associated Sites", 
  adef.org_name "Associated Accounts",
  df.domainname "Domain Name"
FROM 
  aaauser aau 
  INNER JOIN aaalogIN aal ON aau.user_id = aal.user_id 
  LEFT JOIN sduser sdu ON sdu.userid = aau.user_id
  LEFT JOIN usersitemapping usm ON usm.userid = sdu.userid 
  INNER JOIN sitedefinitiON sdef ON sdef.siteid = usm.siteid 
  INNER JOIN accountsitemapping asm ON asm.siteid = sdef.siteid 
  INNER JOIN accountdefinitiON adef ON adef.org_id = asm.accountid 
  INNER JOIN sdorganizatiON sdo ON sdo.org_id = sdef.siteid 
  LEFT  JOIN AaaUserContactInfo ON aau.USER_ID = AaaUserContactInfo.USER_ID 
  LEFT JOIN AaaContactInfo ON AaaUserContactInfo.CONTACTINFO_ID = AaaContactInfo.CONTACTINFO_ID 
  LEFT JOIN domaininfo df ON sdu.domain_id = df.domainid
WHERE aau.user_id IN (
    SELECT 
      technicianid 
    FROM 
      helpdeskcrew   ) and (df.domainname like 'sdpmspad1.com')
ORDER BY 1

                  New to ADSelfService Plus?