Find twins -- create list or group

Here’s the SQL script I use to find multiple births that I’ve yet to identify. The output lists the first person in the multiple births. Then I go into RM and share the birth fact with a role type of “Twin” for each person with the same birth date. I’ve modified the birth fact type sentence to be:

[person:cycle]<, twin <%brother |sister |>of [Twin:First],> was born< [Date]>< [PlaceDetails]>< [Place]>.

The sentence template for the twin role is blank.

–Find Twins, etc in RM database
select PT.PersonID, NT.Given, NT.Surname, ET.Date, PT.ParentID, WT.WitnessID
from PersonTable as PT
inner join EventTable as ET on ET.OwnerID = PT.PersonID
inner join NameTable as NT on NT.OwnerID = PT.PersonID
full outer join WitnessTable as WT on WT.EventID = ET.EventID
where ET.EventType = 1 /birthday/
and ET.OwnerType = 0 /*individual event type /
and PT.ParentID <> 0 /0 has no parents/
and ET.date <> ‘.’
and NT.IsPrimary = 1 /
not and alternate name */
and WT.WitnessID is null /*only those multiple births not previously identified /
group by PT.ParentID, ET.Date
having count(
) > 1
order by PT.PersonID

1 Like