SELECT aaauser.user_id "userid",aaauser.first_name AS "name",AaaLogin.DOMAINNAME "domain" FROM PortalUsers
LEFT JOIN SDUser sduser ON portalusers.USERID=sduser.USERID
left join aaauser on sduser.userid=aaauser.user_id
LEFT JOIN AaaUserContactInfo ON AaaUser.USER_ID=AaaUserContactInfo.USER_ID
LEFT JOIN AaaContactInfo ON AaaUserContactInfo.CONTACTINFO_ID=AaaContactInfo.CONTACTINFO_ID
LEFT JOIN AaaLogin ON AaaUser.USER_ID=AaaLogin.USER_ID
where sduser.status='ACTIVE' and portalusers.userid not in (select userid from portaltechnicians) and
AaaLogin.DOMAINNAME = 'sdptest'