Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions ehr/resources/queries/study/animalIdsAsDamAndSire.sql
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@

SELECT DISTINCT dam AS Id,
gender,
species
SELECT Id.parents.dam AS parent,
gender,
species
FROM demographics
WHERE dam IN (SELECT sire FROM demographics)

UNION

SELECT DISTINCT sire AS Id,
gender,
species
FROM demographics
WHERE sire IN (SELECT dam FROM demographics);
WHERE Id.parents.dam IN (SELECT Id.parents.sire FROM demographics)
4 changes: 2 additions & 2 deletions ehr/resources/queries/study/parentsDifferentSpecies.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SELECT
ELSE FALSE
END as parentSpeciesMismatch
FROM demographics d1
LEFT JOIN demographics d2 ON d1.dam = d2.Id
LEFT JOIN demographics d3 ON d1.sire = d3.Id
LEFT JOIN demographics d2 ON d1.Id.parents.dam = d2.Id
LEFT JOIN demographics d3 ON d1.Id.parents.sire = d3.Id
) d4
WHERE d4.parentSpeciesMismatch = TRUE
4 changes: 2 additions & 2 deletions ehr/resources/queries/study/parentsIncorrectGender.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SELECT
ELSE FALSE
END as parentSpeciesMismatch
FROM demographics d1
LEFT JOIN demographics d2 ON d1.dam = d2.Id
LEFT JOIN demographics d3 ON d1.sire = d3.Id
LEFT JOIN demographics d2 ON d1.Id.parents.dam = d2.Id
LEFT JOIN demographics d3 ON d1.Id.parents.sire = d3.Id
) d4
WHERE d4.parentSpeciesMismatch = TRUE
8 changes: 4 additions & 4 deletions ehr/resources/queries/study/parentsYoungerThanOffspring.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ FROM (
dem.gender,
dem.species,
dem.birth,
dem.dam,
dem.Id.parents.dam,
damDem.birth as damBirth,
dem.sire,
dem.Id.parents.sire,
sireDem.birth as sireBirth
FROM demographics dem
LEFT JOIN demographics damDem ON dem.dam = damDem.Id
LEFT JOIN demographics sireDem ON dem.sire = sireDem.Id
LEFT JOIN demographics damDem ON dem.Id.parents.dam = damDem.Id
LEFT JOIN demographics sireDem ON dem.Id.parents.sire = sireDem.Id
) t
WHERE (t.birth <= t.damBirth OR t.birth <= t.sireBirth)