我有一個名爲tblItemReviewItems的表,我必須爲給定日期中的每個UserId選擇10%的ItemReviewId樣本。 這是表腳本和一些樣本數據:人口選擇所有用戶的樣本並更新樣本的字段值
CREATE TABLE tblItemReviewItems(
ItemReviewId INTEGER NOT NULL PRIMARY KEY
,UserId VARCHAR(50) NOT NULL
,ReviewDate DATE NOT NULL
,Deleted VARCHAR(10) NOT NULL
,Audited VARCHAR(10) NOT NULL
);
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425282,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425291,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425299,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425304,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425311,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425324,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425333,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425358,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425423,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425443,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425482,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425547,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425580,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425899,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425921,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16426037,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16426239,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16426257,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16426787,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427205,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427428,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427465,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427506,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427545,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427596,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427615,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427841,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427860,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427908,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16428038,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16428200,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16428665,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429222,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429240,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429254,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429275,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429283,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429642,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429653,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429658,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429671,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429691,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429706,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429718,'jdoe1','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427072,'jdoe1','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427221,'jdoe1','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427299,'jdoe1','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427628,'jdoe1','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16428359,'jdoe1','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16428988,'jdoe1','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429003,'jdoe1','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429346,'jdoe1','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430270,'jdoe1','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16431587,'jdoe1','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16432199,'jdoe1','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16433774,'jdoe1','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16434065,'jdoe1','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16435062,'jdoe1','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16435667,'jdoe1','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16435702,'jdoe1','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425351,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425396,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425472,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16426042,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16426260,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427379,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427497,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427553,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427568,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427575,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427595,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427613,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427653,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427688,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427698,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427877,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16428006,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16428031,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16428353,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16428375,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16428827,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16428883,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16428929,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429004,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429121,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429138,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429624,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429647,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429776,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429837,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429890,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430032,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430061,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430100,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430158,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430173,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430223,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430311,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430357,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430440,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430471,'jdoe2','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425491,'jdoe2','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425629,'jdoe2','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425722,'jdoe2','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16426266,'jdoe2','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427719,'jdoe2','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427957,'jdoe2','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16428401,'jdoe2','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429028,'jdoe2','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429146,'jdoe2','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16431275,'jdoe2','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16431558,'jdoe2','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16432351,'jdoe2','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16432521,'jdoe2','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16434592,'jdoe2','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16434822,'jdoe2','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16435461,'jdoe2','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16435562,'jdoe2','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16435658,'jdoe2','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16435694,'jdoe2','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425249,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425393,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425513,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425575,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425604,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425906,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427509,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16428876,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16428889,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16428937,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16428966,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16428977,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429001,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429036,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429062,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429096,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429118,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429809,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429944,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429984,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430038,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430048,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430115,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430140,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430189,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430339,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430368,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430420,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430439,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430467,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430651,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430656,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430663,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430842,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430846,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430876,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16431068,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16431080,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16431100,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16431475,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16431517,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16431545,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16431572,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16431616,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16431753,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16431792,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16431803,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16431812,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16431833,'jdoe3','7/1/2017','Yes','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16425929,'jdoe3','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16427532,'jdoe3','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429660,'jdoe3','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16429819,'jdoe3','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16430204,'jdoe3','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16431287,'jdoe3','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16432004,'jdoe3','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16434233,'jdoe3','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16434999,'jdoe3','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16435056,'jdoe3','7/1/2017','No','No');
INSERT INTO tblItemReviewItems(ItemReviewId,UserId,ReviewDate,Deleted,Audited) VALUES (16435798,'jdoe3','7/1/2017','No','No');
ALTER PROC [dbo].[spPickSample]
AS
BEGIN
DECLARE @Nos INT = (SELECT COUNT (*) FROM tblItemReviewItems WHERE Deleted='No' and UserId='jdoe1')
DECLARE @Yes INT = (SELECT COUNT (*) FROM tblItemReviewItems WHERE Deleted='Yes' and UserId='jdoe1')
DECLARE @Samplepct FLOAT =(.05*(@Nos + @Yes))/@Nos*100
DECLARE @Percentage AS INT = @Samplepct
SELECT
TOP (@Percentage) PERCENT *
FROM
tblItemReviewItems
WHERE
Deleted='No' AND UserId='jdoe1'
ORDER BY
NEWID()
END
5%應來自刪除(否)和人口的5%應來自刪除(是)。
人口:
+-------------+----+-----+-------------+
| UserId | No | Yes | Grand Total |
+-------------+----+-----+-------------+
| jdoe1 | 16 | 44 | 60 |
| jdoe2 | 19 | 41 | 60 |
| jdoe3 | 11 | 49 | 60 |
| Grand Total | 46 | 134 | 180 |
+-------------+----+-----+-------------+
目標樣本:
+-------------+----+-----+-------------+
| UserId | No | Yes | Grand Total |
+-------------+----+-----+-------------+
| jdoe1 | 3 | 3 | 6 |
| jdoe2 | 3 | 3 | 6 |
| jdoe3 | 3 | 3 | 6 |
| Grand Total | 9 | 9 | 18 |
+-------------+----+-----+-------------+
這是我試圖獲得:
+--------------+--------+------------+---------+---------+
| ItemReviewId | UserId | ReviewDate | Deleted | Audited |
+--------------+--------+------------+---------+---------+
| 16427072 | jdoe1 | 7/1/2017 | No | Check |
| 16428359 | jdoe1 | 7/1/2017 | No | Check |
| 16429003 | jdoe1 | 7/1/2017 | No | Check |
| 16429222 | jdoe1 | 7/1/2017 | Yes | Check |
| 16428665 | jdoe1 | 7/1/2017 | Yes | Check |
| 16425311 | jdoe1 | 7/1/2017 | Yes | Check |
| 16426266 | jdoe2 | 7/1/2017 | No | Check |
| 16432521 | jdoe2 | 7/1/2017 | No | Check |
| 16435694 | jdoe2 | 7/1/2017 | No | Check |
| 16427379 | jdoe2 | 7/1/2017 | Yes | Check |
| 16427568 | jdoe2 | 7/1/2017 | Yes | Check |
| 16427877 | jdoe2 | 7/1/2017 | Yes | Check |
| 16427532 | jdoe3 | 7/1/2017 | No | Check |
| 16435798 | jdoe3 | 7/1/2017 | No | Check |
| 16429660 | jdoe3 | 7/1/2017 | No | Check |
| 16430140 | jdoe3 | 7/1/2017 | Yes | Check |
| 16430339 | jdoe3 | 7/1/2017 | Yes | Check |
| 16428937 | jdoe3 | 7/1/2017 | Yes | Check |
+--------------+--------+------------+---------+---------+
這是我曾嘗試:
ALTER PROC [dbo].[PickSample]
(
@ReviewDate AS DATETIME
,@UserId AS NVARCHAR(50)
)
AS
BEGIN
DECLARE @tempDashboard table
(
ItemReviewId VarChar(50)
,UserId VarChar(50)
,ReviewDate Datetime
,Deleted varchar(10)
,Audited varchar(10)
)
DECLARE @Nos INT = (SELECT COUNT (*) FROM tblItemReviewItems WHERE Deleted='No' AND [email protected] AND [email protected])
DECLARE @Yes INT = (SELECT COUNT (*) FROM tblItemReviewItems WHERE Deleted='Yes' AND [email protected] AND [email protected])
DECLARE @Samplepct FLOAT =(.05*(@Nos + @Yes))/@Nos*100
DECLARE @Percentage AS INT = @Samplepct
INSERT INTO @tempDashboard (ItemReviewId, UserId, ReviewDate, Deleted, Audited)
SELECT
TOP (@Percentage) PERCENT ItemReviewId, UserId, ReviewDate, Deleted, Audited
FROM
tblItemReviewItems
WHERE
Deleted='No' AND [email protected] AND [email protected]
ORDER BY
NEWID()
DECLARE @Nos2 INT = (SELECT COUNT (*) FROM tblItemReviewItems WHERE Deleted='No' AND [email protected] AND [email protected])
DECLARE @Yes2 INT = (SELECT COUNT (*) FROM tblItemReviewItems WHERE Deleted='Yes' AND [email protected] AND [email protected])
DECLARE @Samplepct2 FLOAT =(.05*(@Nos2 + @Yes2))/@Yes2*100
DECLARE @Percentage2 AS INT = @Samplepct2
INSERT INTO @tempDashboard (ItemReviewId, UserId, ReviewDate, Deleted, Audited)
SELECT
TOP (@Percentage2) PERCENT ItemReviewId, UserId, ReviewDate, Deleted, Audited
FROM
tblItemReviewItems
WHERE
Deleted='Yes' AND [email protected] AND [email protected]
ORDER BY
NEWID()
UPDATE a
SET Audited='Check'
FROM tblItemReviewItems AS a
INNER JOIN @tempDashboard AS b
ON b.ItemReviewId=a.ItemReviewId
END
我必須爲每個用戶運行存儲過程。通常每天大約有200個用戶。所以我將不得不在一天內運行存儲過程200次。我如何一次性實現這一目標?
你有tblItemReviewItems的主鍵? – Jayvee
@Jayvee表中有一個主鍵「ItemReviewId」。 –
好的,你可以選擇頂部@percentage百分比ItemReviewedId到臨時表或表變量或cte中,並用它來選擇項目並更新它們 – Jayvee