Definition
Information
Section titled “Information”The Dbo Sex model holds sex classification descriptions. Each entry records a sex identifier, description and code identifier, together with organisation information.
Soft-Deleted Records
Section titled “Soft-Deleted Records”_deleted indicates whether the record has been deleted in the source system.
Examples
Section titled “Examples”dbo.sex with dbo.codelookup details
Section titled “dbo.sex with dbo.codelookup details”Return records alongside descriptive values from the related dbo.codelookup record.
:::caution[Unverified join] This join is inferred from matching column names and is not part of the documented relationships. Check the results before relying on it. :::
SELECT m."sexid", m."codeid", p1."term" AS "codelookup_term"FROM dbo.sex AS mLEFT JOIN dbo.codelookup AS p1 ON p1."emiscodeid" = m."codeid" AND p1."organisation" = m."organisation";Row count by dbo.codelookup term
Section titled “Row count by dbo.codelookup term”Count dbo.sex records for each dbo.codelookup value, joined on codeid.
:::caution[Unverified join] This join is inferred from matching column names and is not part of the documented relationships. Check the results before relying on it. :::
SELECT p."term" AS "codelookup_term", COUNT(*) AS row_countFROM dbo.sex AS mINNER JOIN dbo.codelookup AS p ON p."emiscodeid" = m."codeid" AND p."organisation" = m."organisation"GROUP BY p."term"ORDER BY row_count DESC;Records without a matching dbo.codelookup
Section titled “Records without a matching dbo.codelookup”Find dbo.sex records whose codeid has no matching dbo.codelookup record.
:::caution[Unverified join] This join is inferred from matching column names and is not part of the documented relationships. Check the results before relying on it. :::
SELECT COUNT(*) AS unmatched_countFROM dbo.sex AS mLEFT JOIN dbo.codelookup AS p ON p."emiscodeid" = m."codeid" AND p."organisation" = m."organisation"WHERE m."codeid" IS NOT NULL AND p."emiscodeid" IS NULL;