I have a database containing a table named “Couple” which representing data couples.
This Table contains the following fields: CoupleId, WifeId, HusbandId, startDate, Enddate
where startdate represent the date in which marriage start, and enddate represent the date in which marriage end.
The HusbandId and WifeId are foreign keys from another table called Person where additional information for each person stored.
I need a query that returns the information of women who are married to two man or more at the same time (synchronized wife).
for example , a female with #1 married to male with #2 form 1-1-2012 to 1-5-2012 (dd-mm-yyyy) , and this female (with #1) married to male with #3 from 1-3-2012 to 1-4-2012 ,, this is called a synchronized marriage for female #1
This is one way to do it:
To actually figure out how many concurrent relationships there are for each person, with FromDate and ToDate ranges, is a much more involved query.