@@ -34,26 +34,27 @@ SELECT
3434
3535 (CASE WHEN p3 .parent IS NOT NULL THEN 1 ELSE 0 END +
3636 CASE WHEN coalesce(p2 .parent , b .dam ) IS NOT NULL THEN 1 ELSE 0 END +
37- CASE WHEN coalesce(p1 .parent , b .sire ) IS NOT NULL THEN 1 ELSE 0 END) as numParents
37+ CASE WHEN coalesce(p1 .parent , b .sire ) IS NOT NULL THEN 1 ELSE 0 END) as numParents,
38+ greatest(d .modified , p1 .modified , p2 .modified , p3 .modified , b .modified ) as modified
3839
3940FROM study .demographics d
4041
4142LEFT JOIN (
42- select p1 .id , min (p1 .method ) as method, max (p1 .parent ) as parent
43+ select p1 .id , min (p1 .method ) as method, max (p1 .parent ) as parent, max ( p1 . modified ) as modified
4344 FROM study .parentage p1
4445 WHERE (p1 .method = ' Genetic' OR p1 .method = ' Provisional Genetic' ) AND p1 .relationship = ' Sire' AND p1 .enddate IS NULL
4546 GROUP BY p1 .Id
4647) p1 ON (d .Id = p1 .id )
4748
4849LEFT JOIN (
49- select p2 .id , min (p2 .method ) as method, max (p2 .parent ) as parent
50+ select p2 .id , min (p2 .method ) as method, max (p2 .parent ) as parent, max ( p2 . modified ) as modified
5051 FROM study .parentage p2
5152 WHERE (p2 .method = ' Genetic' OR p2 .method = ' Provisional Genetic' ) AND p2 .relationship = ' Dam' AND p2 .enddate IS NULL
5253 GROUP BY p2 .Id
5354) p2 ON (d .Id = p2 .id )
5455
5556LEFT JOIN (
56- select p3 .id , min (p3 .method ) as method, max (p3 .parent ) as parent
57+ select p3 .id , min (p3 .method ) as method, max (p3 .parent ) as parent, max ( p3 . modified ) as modified
5758 FROM study .parentage p3
5859 WHERE p3 .relationship = ' Foster Dam' AND p3 .enddate IS NULL
5960 GROUP BY p3 .Id
0 commit comments