Script to identify Mis-matched Roles / Sex for shared facts (Census)

Quote from kevync on 2024-02-27, 9:18 amScript to identify Mis-matched Roles / Sex for shared facts - in my case for Census (#18)
This usually happens because daughter is the first one.
I would need to check if a person has Shared census fact "Daughter" and if person is male update role to "Son" for example -- this is probably my most common error. Does anyone have a script that could be adapted for this purpose?
Script to identify Mis-matched Roles / Sex for shared facts - in my case for Census (#18)
This usually happens because daughter is the first one.
I would need to check if a person has Shared census fact "Daughter" and if person is male update role to "Son" for example -- this is probably my most common error. Does anyone have a script that could be adapted for this purpose?
Uploaded files:

Quote from thejerrybryan on 2024-02-27, 11:10 amI don't have such a query sitting on the shelf, but I hacked the following one in a couple of minutes. It's very simpleminded. It really only looks at the name of role and the sex of the person who has the role. It doesn't look at the type of event or the owner of the fact that owns the role. For example, the query doesn't check to see of the name of the event owning the role of Son is Census. It would find any female with the role Son, no matter what event owned the role of Son. But I don't think those things are actually necessary.
You would obviously need to fill in any additional role names of interest and the sex that is incorrect for those roles.
SELECT W.PersonID, R.RoleName, P.Sex, N.Given, N.Surname
FROM WitnessTable AS W
JOIN RoleTable AS R ON W.Role = RoleID
JOIN PersonTable AS P ON P.PersonID = W.PersonID
JOIN NameTable AS N ON N.OwnerID = P.PersonID AND N.NameType = 0
WHERE R.Rolename LIKE 'Husband_death' AND P.Sex != 1
OR R.Rolename LIKE 'Wife_death' AND P.Sex != 0
OR R.Rolename LIKE 'Son' AND P.Sex != 0
OR R.Rolename LIKE 'Daughter' AND P.Sex != 1
I don't have such a query sitting on the shelf, but I hacked the following one in a couple of minutes. It's very simpleminded. It really only looks at the name of role and the sex of the person who has the role. It doesn't look at the type of event or the owner of the fact that owns the role. For example, the query doesn't check to see of the name of the event owning the role of Son is Census. It would find any female with the role Son, no matter what event owned the role of Son. But I don't think those things are actually necessary.
You would obviously need to fill in any additional role names of interest and the sex that is incorrect for those roles.
SELECT W.PersonID, R.RoleName, P.Sex, N.Given, N.Surname
FROM WitnessTable AS W
JOIN RoleTable AS R ON W.Role = RoleID
JOIN PersonTable AS P ON P.PersonID = W.PersonID
JOIN NameTable AS N ON N.OwnerID = P.PersonID AND N.NameType = 0
WHERE R.Rolename LIKE 'Husband_death' AND P.Sex != 1
OR R.Rolename LIKE 'Wife_death' AND P.Sex != 0
OR R.Rolename LIKE 'Son' AND P.Sex != 0
OR R.Rolename LIKE 'Daughter' AND P.Sex != 1

Quote from kevync on 2024-02-27, 11:30 amI was not sure if I was over thinking the joins needed.
This should be easily adapted for what I need and I can make s group using my normal subquery method.
I was not sure if I was over thinking the joins needed.
This should be easily adapted for what I need and I can make s group using my normal subquery method.

Quote from thejerrybryan on 2024-02-27, 12:28 pmSome obvious ones I left out and which you probably already have figured out.
OR R.Rolename LIKE 'Husband' AND P.Sex != 0
OR R.Rolename LIKE 'Wife' AND P.Sex != 1
OR R.Rolename LIKE 'Father' AND P.Sex != 0
OR R.Rolename LIKE 'Mother' AND P.Sex != 1
OR R.Rolename LIKE 'GrandFather' AND P.Sex != 0
OR R.Rolename LIKE 'GrandMother' AND P.Sex != 1
OR R.Rolename LIKE 'Grandson' AND P.Sex != 0
OR R.Rolename LIKE 'GrandDaughter' AND P.Sex != 1
OR R.Rolename LIKE 'Uncle' AND P.Sex != 0
OR R.Rolename LIKE 'Aunt' AND P.Sex != 1
OR R.Rolename LIKE 'Nephew' AND P.Sex != o
OR R.Rolename LIKE 'Niece' AND P.Sex != 1For things like Boarder or Servant, there is no obvious gender identity.
Some obvious ones I left out and which you probably already have figured out.
OR R.Rolename LIKE 'Husband' AND P.Sex != 0
OR R.Rolename LIKE 'Wife' AND P.Sex != 1
OR R.Rolename LIKE 'Father' AND P.Sex != 0
OR R.Rolename LIKE 'Mother' AND P.Sex != 1
OR R.Rolename LIKE 'GrandFather' AND P.Sex != 0
OR R.Rolename LIKE 'GrandMother' AND P.Sex != 1
OR R.Rolename LIKE 'Grandson' AND P.Sex != 0
OR R.Rolename LIKE 'GrandDaughter' AND P.Sex != 1
OR R.Rolename LIKE 'Uncle' AND P.Sex != 0
OR R.Rolename LIKE 'Aunt' AND P.Sex != 1
OR R.Rolename LIKE 'Nephew' AND P.Sex != o
OR R.Rolename LIKE 'Niece' AND P.Sex != 1
For things like Boarder or Servant, there is no obvious gender identity.
