Last active
November 4, 2021 15:39
-
-
Save ipeirotis/6ca23e8ac1c9bee7a0011c698d08092b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
P1.* | |
, COALESCE(P1.count-P2.count,P1.count) AS count_without_missing | |
, P2.count AS count_missing | |
FROM | |
itemsets P1 | |
JOIN itemsets P2 ON (P1.email = P2.email) | |
WHERE | |
P2.itemset_size>=2 AND | |
P1.itemset_size = P2.itemset_size - 1 AND | |
P1.missing_values = 0 AND | |
P2.missing_values = 1 AND | |
(COALESCE(cast((P1.email = P2.email) AS int),0) + COALESCE(cast((P1.phone = P2.phone) AS int),0) + .... = P1.itemset_size) | |
UNION ALL | |
SELECT | |
P1.* | |
, COALESCE(P1.count-P2.count,P1.count) AS count_without_missing | |
, P2.count AS count_missing | |
FROM | |
itemsets P1 | |
JOIN itemsets P2 ON (P1.phone = P2.phone) | |
WHERE | |
P2.itemset_size>=2 AND | |
P1.itemset_size = P2.itemset_size - 1 AND | |
P1.missing_values = 0 AND | |
P2.missing_values = 1 AND | |
(COALESCE(cast((P1.email = P2.email) AS int),0) + COALESCE(cast((P1.phone = P2.phone) AS int),0) + .... = P1.itemset_size) | |
UNION ALL | |
SELECT ... | |
--- continue with the remaining attributes | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment