Skip to content
Partner Developer Portal

Definition

The Appointment Sessionlocation model links appointment sessions with their recorded locations. Each association contains the session and location identifiers together with source organisation information, identifying the session’s recorded location association and the organisational context in which it is stored.

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

appointment.sessionlocation with dbo.location and appointment.session details

Section titled “appointment.sessionlocation with dbo.location and appointment.session details”

Return records alongside descriptive values from the related tables.

SELECT
m."_primary_key",
m."locationid",
p1."locationname" AS "locationname",
m."sessionid",
p2."description" AS "session_description"
FROM appointment.sessionlocation AS m
LEFT JOIN dbo.location AS p1
ON p1."locationid" = m."locationid"
AND p1."organisation" = m."organisation"
LEFT JOIN appointment.session AS p2
ON p2."sessionid" = m."sessionid"
AND p2."organisation" = m."organisation";

Count appointment.sessionlocation records for each dbo.location value, joined on locationid.

SELECT
p."locationname" AS "locationname",
COUNT(*) AS row_count
FROM appointment.sessionlocation AS m
INNER JOIN dbo.location AS p
ON p."locationid" = m."locationid"
AND p."organisation" = m."organisation"
GROUP BY p."locationname"
ORDER BY row_count DESC;

Row count by appointment.session description

Section titled “Row count by appointment.session description”

Count appointment.sessionlocation records for each appointment.session value, joined on sessionid.

SELECT
p."description" AS "session_description",
COUNT(*) AS row_count
FROM appointment.sessionlocation AS m
INNER JOIN appointment.session AS p
ON p."sessionid" = m."sessionid"
AND p."organisation" = m."organisation"
GROUP BY p."description"
ORDER BY row_count DESC;