Sorry to bump this, however, I'm retrying to get this working after getting busy with another project.
Although I'm no longer experiencing errors (which was happening before because apparantly "as over" is not valid, and there was a stray comma), I'm not getting the results I'm expecting or got correctly with the PHP solution above.
Here's the current code, followed by the problem:
$over=0;
$under=0;
$total=0;
$totvar=0;
// Support
$sql = "SELECT COUNT(*) AS `over` FROM supportreply r, support t WHERE user=1 AND r.id_ticket=t.id_ticket AND r.dateadded > t.dateadded AND TIMESTAMPDIFF(SECOND, r.dateadded, t.dateadded)>86400";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$over_support = $row['over'];
$sql = "SELECT COUNT(*) AS `under` FROM supportreply r, support t WHERE user=1 AND r.id_ticket=t.id_ticket AND r.dateadded > t.dateadded AND TIMESTAMPDIFF(SECOND, r.dateadded, t.dateadded)<=86400";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$under_support = $row['under'];
$sql = "SELECT SUM(TIMESTAMPDIFF(SECOND, r.dateadded, t.dateadded)) AS total, SUM(TIMESTAMPDIFF(SECOND, t.dateopened, t.dateadded)) AS totvar FROM supportreply r, support t WHERE user=1 AND r.id_ticket=t.id_ticket AND r.dateadded > t.dateadded";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$total_support = $row['total'];
$totvar_support = $row['totvar'];
===Please remember there a few of these for different tickets, I'm then adding them all together with:===
// Now add them all together...
$over = $over_xxx + $over_xxx + (etc);
$under = $under_xxx + $under_xxx + (etc);
$total = $total_xxx + $total_xxx + (etc);
$totvar = $totvar_xxx + $totvar_xxx + (etc);
The issue is that $under seems to be giving a figure that is even more than how many tickets there are in all the databases combined, so this is not a real figure.
I'm not sure if it's just checking whether the first reply to the ticket was within 24h, or all of them? This is what the PHP solution did, checking whether the first reply to the ticket was within 24 hours, if not, bump up $over, or if not bump up $under.
Because of this, I think this is also causing $total and $totvar to be totally out of whack (which they are in comparison to the PHP solution).
Thanks for any continued help you can provide.