Definition
Information
Section titled “Information”The Unscheduledcare Dischargedestination model holds organisation details for recorded discharge destinations. Each entry contains a destination identifier, organisation identifier and name, ODS code and active flag, together with organisation information.
Soft-Deleted Records
Section titled “Soft-Deleted Records”_deleted indicates whether the record has been deleted in the source system.
Examples
Section titled “Examples”unscheduledcare.dischargedestination with dbo.organisation details
Section titled “unscheduledcare.dischargedestination with dbo.organisation details”Return records alongside descriptive values from the related dbo.organisation record.
SELECT m."dischargedestinationid", m."organisationid", p1."organisationdisplayname" AS "organisationdisplayname"FROM unscheduledcare.dischargedestination AS mLEFT JOIN dbo.organisation AS p1 ON p1."organisationid" = m."organisationid" AND p1."organisation" = m."organisation";unscheduledcare.attendancedetail count per unscheduledcare.dischargedestination
Section titled “unscheduledcare.attendancedetail count per unscheduledcare.dischargedestination”Count related unscheduledcare.attendancedetail records for each unscheduledcare.dischargedestination record, joined on dischargedestinationid.
SELECT m."dischargedestinationid", m."organisationname", COUNT(c."dischargedestinationid") AS attendancedetail_countFROM unscheduledcare.dischargedestination AS mLEFT JOIN unscheduledcare.attendancedetail AS c ON m."dischargedestinationid" = c."dischargedestinationid" AND m."organisation" = c."organisation"GROUP BY m."dischargedestinationid", m."organisationname"ORDER BY attendancedetail_count DESC;Row count by dbo.organisation organisationdisplayname
Section titled “Row count by dbo.organisation organisationdisplayname”Count unscheduledcare.dischargedestination records for each dbo.organisation value, joined on organisationid.
SELECT p."organisationdisplayname" AS "organisationdisplayname", COUNT(*) AS row_countFROM unscheduledcare.dischargedestination 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;