quiz_record
桌子:
我需要计算所有那些具有排marks 不到的marks的Student_Id['4']。
此外,如果其他的标记是关闭相同的的标记Student_Id['4'],然后还指望所有那些time gap (Quiz_End - Quiz_Start)是更比time gap (Quiz_End - Quiz_Start)的Student_Id['4']。
预期结果:2
为此,我尝试了:
$time_taken = strtotime($fetch_quiz_record['Quiz_End']) - strtotime($fetch_quiz_record['Quiz_Start']);
$count_less_played = $user->runQuery("SELECT COUNT(Id) AS Id FROM quiz_record WHERE Quiz_Id=:quiz_id AND Marks<=:marks AND (Quiz_End - Quiz_Start) >:time_diff");
$count_less_played->bindparam(":quiz_id",$fetch_quiz_record['Quiz_Id']);
$count_less_played->bindparam(":marks",$fetch_quiz_record['Marks']);
$count_less_played->bindparam(":time_diff",$time_taken);
$count_less_played->execute();
$count_less_played_cnt = $count_less_played->fetch(PDO::FETCH_ASSOC);
echo $count_less_played_no= $count_less_played_cnt['Id'];
输出:4
繁花如伊
绝地无双