I have such table, column "time" is unix time stamp
nid tid time rtt 139 498 1450609031 0.013079 139 498 1450609033 0.013229 139 498 1450609035 0.012379 139 444 1450609065 0.012479 139 444 1450609165 0.012239 139 444 1450609265 0.023479 139 333 1450619265 0.014379 139 333 1450629212 0.012334 139 333 1450630265 0.023234 140 498 1450640265 0.015379 140 498 1450641212 0.035334 140 498 1450642265 0.025234 140 555 1450650265 0.055379 140 555 1450652212 0.025334 140 555 1450654265 0.055234 ......
What I want is to first create a table like below using sql, making tid as the primary key column, including the largest time for each nid and tid pair
tid nid time rtt 498 139 1450609035 0.012379 444 139 1450609265 0.023479 333 139 1450630265 0.023234
The final result I want is to sum up the rtt above, i.e. 0.012379+0.023479+0.023234=0.059092
Could anyone help me write a sql statement to achieve the result? Thanks a lot!