Definition
Information
Section titled “Information”The Dbo Secondarycareorganisation model holds secondary-care organisation details concerning providers, commissioners, sites and service agreements. It records their codes and reference values, a department-type identifier, a local patient-identifier value and a patient-pathway identifier issuer, together with an organisation identifier.
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.secondarycareorganisation with dbo.organisation details
Section titled “dbo.secondarycareorganisation with dbo.organisation details”Return records alongside descriptive values from the related dbo.organisation record.
SELECT m."_primary_key", m."organisationid", p1."organisationdisplayname" AS "organisationdisplayname"FROM dbo.secondarycareorganisation AS mLEFT JOIN dbo.organisation AS p1 ON p1."organisationid" = m."organisationid" AND p1."organisation" = m."organisation";Row count by dbo.organisation organisationdisplayname
Section titled “Row count by dbo.organisation organisationdisplayname”Count dbo.secondarycareorganisation records for each dbo.organisation value, joined on organisationid.
SELECT p."organisationdisplayname" AS "organisationdisplayname", COUNT(*) AS row_countFROM dbo.secondarycareorganisation 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;Records without a matching dbo.organisation
Section titled “Records without a matching dbo.organisation”Find dbo.secondarycareorganisation records whose organisationid has no matching dbo.organisation record.
SELECT COUNT(*) AS unmatched_countFROM dbo.secondarycareorganisation AS mLEFT JOIN dbo.organisation AS p ON p."organisationid" = m."organisationid" AND p."organisation" = m."organisation"WHERE m."organisationid" IS NOT NULL AND p."organisationid" IS NULL;