Add values from unlimited data range

Hi. I am a newbie. I actually wanted to add and arrange data that I stored in the Firebase.


image
As can be seen from the screenshot, there are a lot of different data in each study. However, I only want to arrange data of “totalcountedvehicles” in ascending order together with the respective “currenttime” data and respective sum of data of “mediumlorry” + “totallightvanutilityvehicle” + “bus” for every four study. For example from 1st Study to 4th Study, 2nd Study to 5th Study, 3rd Study to 6th Study and etc.There is no limitation on the number of study carried out by future users. For example there can be 6,10 or 12 studies done by users.
I tried doing this but didnt get the result I wanted.