Skip to content

Commit 5fcf876

Browse files
committed
Improve SQL
1 parent 67c66bf commit 5fcf876

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
SELECT
2-
t.Id,
2+
coalesce(t.Id, t2.subjectId) as Id,
33
'SIV Infection' as category,
44
t.date as treatmentTableDate,
55
t2.date as subjectAnchorDatesTableDate
66

77
FROM study.treatments t
88
FULL JOIN studies.subjectAnchorDates t2 ON (
9-
t.category = 'SIV Infection' AND
10-
t2.subjectId = t.Id AND
11-
t2.eventLabel = 'SIV Infection'
9+
t.category = t2.eventLabel AND
10+
t2.subjectId = t.Id
1211
)
1312

14-
WHERE t2.date != t.date OR
13+
WHERE (t2.date != t.date OR
1514
t2.date IS NULL OR
16-
t.date IS NULL
15+
t.date IS NULL) AND COALESCE(t.category, t2.eventLabel) = 'SIV Infection'

0 commit comments

Comments
 (0)