Skip to content
Partner Developer Portal

Definition

The Bedmanagement Bedfeature model holds bed-feature definitions, including their codes and descriptions. Each entry records a feature identifier, organisation identifier and source organisation information.

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

bedmanagement.bedfeature with dbo.organisation details

Section titled “bedmanagement.bedfeature with dbo.organisation details”

Return records alongside descriptive values from the related dbo.organisation record.

SELECT
m."bedfeatureid",
m."organisationid",
p1."organisationdisplayname" AS "organisationdisplayname"
FROM bedmanagement.bedfeature AS m
LEFT JOIN dbo.organisation AS p1
ON p1."organisationid" = m."organisationid"
AND p1."organisation" = m."organisation";

bedmanagement.bedhasfeature count per bedmanagement.bedfeature

Section titled “bedmanagement.bedhasfeature count per bedmanagement.bedfeature”

Count related bedmanagement.bedhasfeature records for each bedmanagement.bedfeature record, joined on bedfeatureid.

SELECT
m."bedfeatureid",
m."description",
COUNT(c."bedfeatureid") AS bedhasfeature_count
FROM bedmanagement.bedfeature AS m
LEFT JOIN bedmanagement.bedhasfeature AS c
ON m."bedfeatureid" = c."bedfeatureid"
AND m."organisation" = c."organisation"
GROUP BY m."bedfeatureid", m."description"
ORDER BY bedhasfeature_count DESC;

Row count by dbo.organisation organisationdisplayname

Section titled “Row count by dbo.organisation organisationdisplayname”

Count bedmanagement.bedfeature records for each dbo.organisation value, joined on organisationid.

SELECT
p."organisationdisplayname" AS "organisationdisplayname",
COUNT(*) AS row_count
FROM bedmanagement.bedfeature AS m
INNER JOIN dbo.organisation AS p
ON p."organisationid" = m."organisationid"
AND p."organisation" = m."organisation"
GROUP BY p."organisationdisplayname"
ORDER BY row_count DESC;