Definition
Information
Section titled “Information”The Bedmanagement Bedstatushistory model records historical bed statuses and their change timestamps. It holds the bed and status identifiers, a history-record identifier and a previous-history identifier, together with source organisation information describing the context of the recorded status history.
Soft-Deleted Records
Section titled “Soft-Deleted Records”_deleted indicates whether the record has been deleted in the source system.
Examples
Section titled “Examples”bedmanagement.bedstatushistory with bedmanagement.bed and bedmanagement.bedstatus details
Section titled “bedmanagement.bedstatushistory with bedmanagement.bed and bedmanagement.bedstatus details”Return records alongside descriptive values from the related tables.
SELECT m."bedstatushistoryid", m."bedid", p1."beddisplayname" AS "beddisplayname", m."bedstatusid", p2."bedstatusdescription" AS "bedstatusdescription"FROM bedmanagement.bedstatushistory AS mLEFT JOIN bedmanagement.bed AS p1 ON p1."bedid" = m."bedid" AND p1."organisation" = m."organisation"LEFT JOIN bedmanagement.bedstatus AS p2 ON p2."bedstatusid" = m."bedstatusid" AND p2."organisation" = m."organisation";Row count by bedmanagement.bed beddisplayname
Section titled “Row count by bedmanagement.bed beddisplayname”Count bedmanagement.bedstatushistory records for each bedmanagement.bed value, joined on bedid.
SELECT p."beddisplayname" AS "beddisplayname", COUNT(*) AS row_countFROM bedmanagement.bedstatushistory AS mINNER JOIN bedmanagement.bed AS p ON p."bedid" = m."bedid" AND p."organisation" = m."organisation"GROUP BY p."beddisplayname"ORDER BY row_count DESC;Row count by bedmanagement.bedstatus bedstatusdescription
Section titled “Row count by bedmanagement.bedstatus bedstatusdescription”Count bedmanagement.bedstatushistory records for each bedmanagement.bedstatus value, joined on bedstatusid.
SELECT p."bedstatusdescription" AS "bedstatusdescription", COUNT(*) AS row_countFROM bedmanagement.bedstatushistory AS mINNER JOIN bedmanagement.bedstatus AS p ON p."bedstatusid" = m."bedstatusid" AND p."organisation" = m."organisation"GROUP BY p."bedstatusdescription"ORDER BY row_count DESC;