Definition
Information
Section titled “Information”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.
Soft-Deleted Records
Section titled “Soft-Deleted Records”_deleted indicates whether the record has been deleted in the source system.
Examples
Section titled “Examples”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 mLEFT 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";Row count by dbo.location locationname
Section titled “Row count by dbo.location locationname”Count dbo.organisationlocation records for each dbo.location value, joined on locationid.
SELECT p."locationname" AS "locationname", COUNT(*) AS row_countFROM dbo.organisationlocation AS mINNER 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_countFROM dbo.organisationlocation AS mINNER JOIN dbo.organisation AS p ON p."organisationid" = m."organisationid" AND p."organisation" = m."organisation"GROUP BY p."organisationdisplayname"ORDER BY row_count DESC;