Definition
Information
Section titled “Information”The Childhealth Treatmentcentre model holds treatment-centre details, including a centre code, correspondence telephone number and correspondence-address identifier. It also records location and treatment-centre identifiers, a centre GUID and active and deleted flags, together with the organisation information for the centre.
Soft-Deleted Records
Section titled “Soft-Deleted Records”_deleted indicates whether the record has been deleted in the source system.
Examples
Section titled “Examples”childhealth.treatmentcentre with dbo.location details
Section titled “childhealth.treatmentcentre with dbo.location details”Return records alongside descriptive values from the related dbo.location record.
SELECT m."treatmentcentreid", m."locationid", p1."locationname" AS "locationname"FROM childhealth.treatmentcentre AS mLEFT JOIN dbo.location AS p1 ON p1."locationid" = m."locationid" AND p1."organisation" = m."organisation";childhealth.patienttreatmentcentre count per childhealth.treatmentcentre
Section titled “childhealth.patienttreatmentcentre count per childhealth.treatmentcentre”Count related childhealth.patienttreatmentcentre records for each childhealth.treatmentcentre record, joined on treatmentcentreid.
SELECT m."treatmentcentreid", m."code", COUNT(c."treatmentcentreid") AS patienttreatmentcentre_countFROM childhealth.treatmentcentre AS mLEFT JOIN childhealth.patienttreatmentcentre AS c ON m."treatmentcentreid" = c."treatmentcentreid" AND m."organisation" = c."organisation"GROUP BY m."treatmentcentreid", m."code"ORDER BY patienttreatmentcentre_count DESC;Row count by dbo.location locationname
Section titled “Row count by dbo.location locationname”Count childhealth.treatmentcentre records for each dbo.location value, joined on locationid.
SELECT p."locationname" AS "locationname", COUNT(*) AS row_countFROM childhealth.treatmentcentre 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;