mardi 30 décembre 2014

How to calculate a total by comparing current and next row


I have a table with some rows: enter image description here


I have a few questions to accomplish the task altogether. Is it possible to calculate total of transmitted and received based on checked_date and ip and connect_time using mysql query? If yes, can I use logical operators to calculate total of transmitted and received? To get correct total transmitted and received I need to use a formula like:



if connect_time[i] > connect_time[j]
then total += transmitted[i]+transmitted[j]
else total += ABS(transmitted[i]-transmitted[j])
end


How to get it done with this formula, does anyone have an idea? P.S. i = current row and j = next row.





Aucun commentaire:

Enregistrer un commentaire