Query to show account,site and its departments (MSSQL & PGSQL)

Query to show account,site and its departments (MSSQL & PGSQL)

Tested in Build PGSQL (14300) or MSSQL (14306)

Please go to Reports-New Query Report and execute this query.

select deptdef.deptname "Department",sdo.name "Site", adef.org_name "Account"  from departmentdefinition deptdef LEFT JOIN sitedefinition sdef on deptdef.siteid=sdef.siteid LEFT JOIN accountsitemapping asm on asm.siteid=sdef.siteid LEFT JOIN accountdefinition adef on adef.org_id=asm.accountid LEFT JOIN sdorganization sdo on sdo.org_id=sdef.siteid ORDER BY 3

                  New to ADSelfService Plus?