{"publisher":"WESWOO","id":"size-demand-stock-days","title":{"zh":"查看样例记录与复算 SQL","en":"Inspect the example records and SQL"},"scope":{"zh":"独立构造的运营记录。每个对照均从同一份初始数据重新开始。金额如无特别说明均为最小货币单位。","en":"Constructed operating records. Each check starts from the original setup. Monetary fields use minor currency units unless stated otherwise."},"setup_sql":"CREATE TABLE size_week(size TEXT,units INT,in_stock_days INT);\nINSERT INTO size_week VALUES ('2X',6,2),('M',10,10);","query_sql":"SELECT size,units,in_stock_days,ROUND(1.0*units/NULLIF(in_stock_days,0),2) AS units_per_stock_day FROM size_week ORDER BY size;","checks":[{"condition":"One size available for only two of ten days","change_sql":"","expected":[["2X",6,2,3],["M",10,10,1]],"observed":[["2X",6,2,3],["M",10,10,1]]},{"condition":"Equal exposure","change_sql":"UPDATE size_week SET in_stock_days=10 WHERE size='2X';","expected":[["2X",6,10,0.6],["M",10,10,1]],"observed":[["2X",6,10,0.6],["M",10,10,1]]},{"condition":"Never offered in this window","change_sql":"UPDATE size_week SET in_stock_days=0,units=0 WHERE size='2X';","expected":[["2X",0,0,null],["M",10,10,1]],"observed":[["2X",0,0,null],["M",10,10,1]]}]}