{"publisher":"WESWOO","id":"shipping-tier-penny-gaps","engine":"SQLite","title":{"zh":"查看样例记录与复核查询","en":"Inspect sample records and query"},"setup_sql":"CREATE TABLE tier(zone TEXT,lo INT,hi INT,label TEXT);\nINSERT INTO tier VALUES ('East',0,10000,'standard'),('East',10100,20000,'large'),('East',20001,NULL,'upper'),('West',0,NULL,'other zone');\nCREATE TABLE cart(cents INT PRIMARY KEY);INSERT INTO cart VALUES (10000),(10001),(10050),(10100),(50000);","query_sql":"SELECT cents,COUNT(label) AS matching_rates FROM cart LEFT JOIN tier ON zone='East'\n AND cents>=lo AND (hi IS NULL OR cents<=hi) GROUP BY cents ORDER BY cents;","checks":[{"condition":"Gap after 100.00","change_sql":"","expected":[[10000,1],[10001,0],[10050,0],[10100,1],[50000,1]],"observed":[[10000,1],[10001,0],[10050,0],[10100,1],[50000,1]]},{"condition":"Start next range at 100.01","change_sql":"UPDATE tier SET lo=10001 WHERE label='large';","expected":[[10000,1],[10001,1],[10050,1],[10100,1],[50000,1]],"observed":[[10000,1],[10001,1],[10050,1],[10100,1],[50000,1]]},{"condition":"Both rates include 100.00","change_sql":"UPDATE tier SET lo=10000 WHERE label='large';","expected":[[10000,2],[10001,1],[10050,1],[10100,1],[50000,1]],"observed":[[10000,2],[10001,1],[10050,1],[10100,1],[50000,1]]},{"condition":"Last tier ends before 500.00","change_sql":"UPDATE tier SET hi=45000 WHERE label='upper';","expected":[[10000,1],[10001,0],[10050,0],[10100,1],[50000,0]],"observed":[[10000,1],[10001,0],[10050,0],[10100,1],[50000,0]]}]}