{"id":"segment-recipient-gap","publisher":"WESWOO","engine":"SQLite","title":{"zh":"查看样例与复核查询","en":"View records and verification query"},"setup_sql":"CREATE TABLE members(customer TEXT PRIMARY KEY);\nCREATE TABLE log(campaign TEXT,customer TEXT,status TEXT);\nINSERT INTO members VALUES ('A'),('B'),('C'),('D');\nINSERT INTO log VALUES ('launch','A','sent'),('launch','A','sent'),('launch','B','bounced'),\n ('launch','C','excluded'),('earlier','D','sent');","query_sql":"SELECT customer,CASE WHEN EXISTS(SELECT 1 FROM log WHERE campaign='launch' AND log.customer=m.customer AND status IN ('sent','bounced')) THEN 'attempted'\n WHEN EXISTS(SELECT 1 FROM log WHERE campaign='launch' AND log.customer=m.customer AND status='excluded') THEN 'documented exclusion'\n ELSE 'no matched event' END AS finding FROM members m ORDER BY customer;","checks":[{"condition":"Launch log versus frozen list","change_sql":"","expected":[["A","attempted"],["B","attempted"],["C","documented exclusion"],["D","no matched event"]],"observed":[["A","attempted"],["B","attempted"],["C","documented exclusion"],["D","no matched event"]]},{"condition":"D gains a launch send","change_sql":"INSERT INTO log VALUES ('launch','D','sent');","expected":[["A","attempted"],["B","attempted"],["C","documented exclusion"],["D","attempted"]],"observed":[["A","attempted"],["B","attempted"],["C","documented exclusion"],["D","attempted"]]},{"condition":"C has no exclusion record","change_sql":"DELETE FROM log WHERE customer='C';","expected":[["A","attempted"],["B","attempted"],["C","no matched event"],["D","no matched event"]],"observed":[["A","attempted"],["B","attempted"],["C","no matched event"],["D","no matched event"]]},{"condition":"Later join outside frozen list","change_sql":"INSERT INTO log VALUES ('launch','E','sent');","expected":[["A","attempted"],["B","attempted"],["C","documented exclusion"],["D","no matched event"]],"observed":[["A","attempted"],["B","attempted"],["C","documented exclusion"],["D","no matched event"]]}]}