Forum

Please or Register to create posts and topics.

SQL - Create group people with duplicate fact (Birth)

The following could be adapted to any event type (Death/burial etc) -- but does for Birth.

-- Create Named Group if it does not exist 'SQL: Duplicate Birth'

INSERT OR IGNORE INTO TagTable
VALUES
(
(SELECT TagID FROM TagTable WHERE TagName LIKE 'SQL: Duplicate Birth')
,0
,(SELECT IFNULL(MAX(TagValue),0)+1 FROM TagTable)
,'SQL: Duplicate Birth'
,'SQLite query'
,julianday('now') - 2415018.5
)
;

-- Delete all members of the named group
DELETE FROM GroupTable
WHERE GroupID =
(SELECT TagValue
FROM TagTable
WHERE TagName
LIKE 'SQL: Duplicate Birth'
)
;
-- Add members to the named group
INSERT INTO GroupTable
SELECT
null
,(SELECT TagValue
FROM TagTable
WHERE TagName
LIKE 'SQL: Duplicate Birth'
)
,PersonID AS StartID
,PersonID AS EndID
,(julianday('now') - 2415018.5) AS UTCModDate

FROM
(
SELECT et.OwnerID as PersonID
FROM EventTable et
Where et.OwnerType = 0 and EventType = 1 -- Birth (change EventType to what you need)
Group BY et.OwnerID
Having count(EventID) > 1
)

 

 

thejerrybryan has reacted to this post.
thejerrybryan