一旦我问了这个问题,但我没有得到解决方案。 我有结果表 像这样的视觉:
查询:
$results = $mysqli->query("
SELECT
T1.bc2014_id, klass, nimi, synd, teamnimi, start,
TIME(`finish`) AS finish,
timediff(time(finish), time(start)) AS aeg,
finish - start as elapsed_time
FROM bc2014 T1
INNER JOIN bc2014aeg T2 on T1.bc2014_id = T2.bc2014_id
WHERE klass = 'DCM (koerakross, mehed al. 14 a.)'
ORDER BY aeg ");
PHP表:
print '<table class="mytable7">';
echo "<tr><th> Class DCM </th></tr>";
print '</table>';
print '<table class="mytable7">';
echo "<tr><th>Place</th><th>ID </th><th>clas </th><th>Name </th><th>Start</th>
<th>Finish</th><th>Time</th><th>DifLeader</th><th>DifPrevios</th><th>KM/h</th></tr>";
while($row = $results->fetch_array()) {
print '<tr>';
print '<td>'.$row["ranking"].'</td>';
print '<td>'.$row["bc2014_id"].'</td>';
print '<td>'.removeParanthesis($row["klass"]).'</td>';
print '<td>'.$row["nimi"].'</td>';
print '<td>'.$row["start"].'</td>';
print '<td>'.$row["finish"].'</td>';
print '<td>'.$row["aeg"].'</td>';
print '<td>'.$row["difleader"].'</td>';
print '<td>'.$row["difprev"].'</td>';
print '<td>'.$row["speed"].'</td>';
print '</tr>';
}
print '</table>';
$results->free();
MySQL时间表结构:
来自MySQL时间表的信息:
我无法在Leader和Previous之间运行时差。 当距离为15 km时计算速度(km / h)的工作奖金
在结束表中应该如下所示 4
答案 0 :(得分:0)
我看到你正在努力解决这个问题。如果你想要简单但又脏的解决方案,那么将这4行添加到SELECT语句中(在“finish - start as elapsed_time”之后):
if (@bestFinish <= finish, timediff(TIME(finish), TIME(@bestFinish)), '00:00:00') as difleader,
if (@previousFinish <= finish, timediff(TIME(finish), TIME(@previousFinish)), '00:00:00') as difprev,
@previousFinish := finish,
@bestFinish := if (@bestFinish > finish, finish, @bestFinish)