Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save tu-trinh-scale/e800f3d5f4b87da1e220d97190e74545 to your computer and use it in GitHub Desktop.

Select an option

Save tu-trinh-scale/e800f3d5f4b87da1e220d97190e74545 to your computer and use it in GitHub Desktop.
WITH threshold_calc AS (
SELECT AVG("aCL IgM") + AVG("aCL IgM") * 0.2 as acl_igm_threshold
FROM Examination
WHERE "aCL IgM" IS NOT NULL
),
core_patients AS (
SELECT DISTINCT ID
FROM Examination
)
SELECT DISTINCT e.Symptoms
FROM Examination e
CROSS JOIN threshold_calc t
WHERE e.ID IN (SELECT ID FROM core_patients)
AND e."Examination Date" >= '1995-01-01'
AND e."Examination Date" <= '1999-12-31'
AND e.Thrombosis IN ('limited', 'partial', 'segmental', 'non-occlusive', '2')
AND e."ANA Pattern" LIKE '%S%'
AND e."aCL IgM" < t.acl_igm_threshold
AND e.Symptoms IS NOT NULL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment