mysql - Finding averages timestamp based on two rows -


basically i'm attempting average based on 2 time stamps inside database, let's example have product, insert database 10 times listed_time , sell_time, want group 10 rows , find average between both listed_time , sell_time find on average on how long took sell.

edit : timestamps inserted time() not date()

the code in tried , failed work was

$query = $db->runsql("select avg(timestampdiff(second, listed_time, sell_time)) trade"); while($row = mysql_fetch_assoc($query)) {     echo $row['avg(timestampdiff(second, listed_time, sell_time))']."</br>"; } 

you can try 10 rows:

select avg(timestampdiff(second, listed_time, sell_time ) ) za_avg ... 

this give average time (for 10 rows) took sell items


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -