Skip to content
Partner Developer Portal

Definition

The Unscheduledcare Conveyingambulancetrust model holds reference details for conveying ambulance trusts. Each entry records a trust identifier, display name and ODS code, together with organisation information.

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

unscheduledcare.attendancedetail count per unscheduledcare.conveyingambulancetrust

Section titled “unscheduledcare.attendancedetail count per unscheduledcare.conveyingambulancetrust”

Count related unscheduledcare.attendancedetail records for each unscheduledcare.conveyingambulancetrust record, joined on conveyingambulancetrustid.

SELECT
m."conveyingambulancetrustid",
m."displayname",
COUNT(c."conveyingambulancetrustid") AS attendancedetail_count
FROM unscheduledcare.conveyingambulancetrust AS m
LEFT JOIN unscheduledcare.attendancedetail AS c
ON m."conveyingambulancetrustid" = c."conveyingambulancetrustid"
AND m."organisation" = c."organisation"
GROUP BY m."conveyingambulancetrustid", m."displayname"
ORDER BY attendancedetail_count DESC;

unscheduledcare.attendancedetail records with unscheduledcare.conveyingambulancetrust details

Section titled “unscheduledcare.attendancedetail records with unscheduledcare.conveyingambulancetrust details”

List unscheduledcare.attendancedetail records with the unscheduledcare.conveyingambulancetrust values they reference through conveyingambulancetrustid.

SELECT
c."attendancedetailid",
c."arrivedon",
m."conveyingambulancetrustid",
m."displayname" AS "conveyingambulancetrust_displayname"
FROM unscheduledcare.attendancedetail AS c
INNER JOIN unscheduledcare.conveyingambulancetrust AS m
ON m."conveyingambulancetrustid" = c."conveyingambulancetrustid"
AND m."organisation" = c."organisation";

unscheduledcare.conveyingambulancetrust records not used by unscheduledcare.attendancedetail

Section titled “unscheduledcare.conveyingambulancetrust records not used by unscheduledcare.attendancedetail”

Find unscheduledcare.conveyingambulancetrust records that no unscheduledcare.attendancedetail record references.

SELECT
m."conveyingambulancetrustid",
m."displayname"
FROM unscheduledcare.conveyingambulancetrust AS m
WHERE NOT EXISTS (
SELECT 1
FROM unscheduledcare.attendancedetail AS c
WHERE m."conveyingambulancetrustid" = c."conveyingambulancetrustid"
AND m."organisation" = c."organisation"
);