My suggestion would be to loop to each connection then get the total query for that connection then calculate the total.