Skip to content
Partner Developer Portal

Definition

The Dbo Organisationlocation model records associations between organisations and locations. Each entry holds organisation and location identifiers and a main-location flag, together with the organisation information recorded for the association and an additional source SCN value for that entry.

_deleted indicates whether the record has been deleted in the source system.

dbo.organisationlocation with dbo.location and dbo.organisation details

Section titled “dbo.organisationlocation with dbo.location and dbo.organisation details”

Return records alongside descriptive values from the related tables.

SELECT
m."_primary_key",
m."locationid",
p1."locationname" AS "locationname",
m."organisationid",
p2."organisationdisplayname" AS "organisationdisplayname"
FROM dbo.organisationlocation AS m
LEFT JOIN dbo.location AS p1
ON p1."locationid" = m."locationid"
AND p1."organisation" = m."organisation"
LEFT JOIN dbo.organisation AS p2
ON p2."organisationid" = m."organisationid"
AND p2."organisation" = m."organisation";

Count dbo.organisationlocation records for each dbo.location value, joined on locationid.

SELECT
p."locationname" AS "locationname",
COUNT(*) AS row_count
FROM dbo.organisationlocation AS m
INNER JOIN dbo.location AS p
ON p."locationid" = m."locationid"
AND p."organisation" = m."organisation"
GROUP BY p."locationname"
ORDER BY row_count DESC;

Row count by dbo.organisation organisationdisplayname

Section titled “Row count by dbo.organisation organisationdisplayname”

Count dbo.organisationlocation records for each dbo.organisation value, joined on organisationid.

SELECT
p."organisationdisplayname" AS "organisationdisplayname",
COUNT(*) AS row_count
FROM dbo.organisationlocation AS m
INNER JOIN dbo.organisation AS p
ON p."organisationid" = m."organisationid"
AND p."organisation" = m."organisation"
GROUP BY p."organisationdisplayname"
ORDER BY row_count DESC;