我试图在一个垃圾箱中随机选择 30% 的票。下面的代码适用于 30%,但是当我在末尾添加“ORDER BY RND(INT(NOW*ID)-NOW*ID)”时,出现错误。
作品:
$result1 = "SELECT MainBin.Assignee, Count(MainBin.IncidentNumber) * .3 AS CountOfIncidentNumber FROM MainBin GROUP BY MainBin.Assignee";
$rs1=odbc_exec($conn,$result1);
while($row = odbc_fetch_array($rs1))
{
$Assignee = "". $row['Assignee'];
$CountOfIncidentNumber = ceil($row["CountOfIncidentNumber"]);
$result2 = "INSERT INTO TicketBin (IncidentNumber)
SELECT TOP $CountOfIncidentNumber IncidentNumber FROM MainBin
WHERE Assignee = '$Assignee'";
$rs2=odbc_exec($conn,$result2);
}
不工作:
$result1 = "SELECT MainBin.Assignee, Count(MainBin.IncidentNumber) * .3 AS CountOfIncidentNumber FROM MainBin GROUP BY MainBin.Assignee ORDER BY RND(INT(NOW*ID)-NOW*ID)";
$rs1=odbc_exec($conn,$result1);
我有一个名为 ID 的 AutoNumber 字段,我以前用过这个,只是没有分组。任何帮助表示赞赏!