Skip to content
Partner Developer Portal

Definition

The Bedmanagement Colour model holds colour definitions for bed management. Each entry records red, green, blue and alpha component values, a colour identifier and source organisation information.

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

bedmanagement.bed count per bedmanagement.colour

Section titled “bedmanagement.bed count per bedmanagement.colour”

Count related bedmanagement.bed records for each bedmanagement.colour record, joined on colourid.

SELECT
m."colourid",
m."alpha",
COUNT(c."colourid") AS bed_count
FROM bedmanagement.colour AS m
LEFT JOIN bedmanagement.bed AS c
ON m."colourid" = c."colourid"
AND m."organisation" = c."organisation"
GROUP BY m."colourid", m."alpha"
ORDER BY bed_count DESC;

bedmanagement.bed records with bedmanagement.colour details

Section titled “bedmanagement.bed records with bedmanagement.colour details”

List bedmanagement.bed records with the bedmanagement.colour values they reference through colourid.

SELECT
c."bedid",
m."colourid",
m."alpha" AS "colour_alpha"
FROM bedmanagement.bed AS c
INNER JOIN bedmanagement.colour AS m
ON m."colourid" = c."colourid"
AND m."organisation" = c."organisation";

bedmanagement.colour records not used by bedmanagement.bed

Section titled “bedmanagement.colour records not used by bedmanagement.bed”

Find bedmanagement.colour records that no bedmanagement.bed record references.

SELECT
m."colourid",
m."alpha"
FROM bedmanagement.colour AS m
WHERE NOT EXISTS (
SELECT 1
FROM bedmanagement.bed AS c
WHERE m."colourid" = c."colourid"
AND m."organisation" = c."organisation"
);