0

I want to calculate the distance between multiple coordinates by time in sql. For example the car passes at point A at 1pm, and then at point B at 3 pm and in the end at point C at 6 pm. Points are connected among each other by the timestamp. So if the car has been in point A at 1 pm and then at point B at 3 pm and Point C at 6 pm. First the distance A to B is calculated and then B to C, and in the end we get the sum of these three points.I want to get the distance that the car passes per 1 day. The car can pass different number of points. For example it can go A->B->C->A or just A->B

I have tables for the CarId,CheckpointCordinates and datastamps.

Can you please guide me how to solve the problem. This question is asked once in here but no answer was given.

Thank you

Strawberry
  • 33,750
  • 13
  • 40
  • 57
Amehiny
  • 125
  • 4
  • 16
  • 2
    Which is it? MySQL or SQL Server? –  Dec 18 '14 at 10:22
  • 2
    Add some sample data and expected output – Pரதீப் Dec 18 '14 at 10:22
  • SQL SERVER. Coordinates: A (3,4) , B(4,5) , C(6,10) The car at 1 pm has been at point A , at 3 pm has been at point B and at 6 pm Point C. So since the time at A is 1 and at B is 3 we take this distance first so d=(1,1) = 1 , and later we take d(B,C) = (2,5)=4.5m Total will be 5.5 – Amehiny Dec 18 '14 at 10:26
  • Add the sample data in question in table format – Pரதீப் Dec 18 '14 at 10:33
  • Car: CarId, ChipId ,,,, Registration: RegistrationId, Coordinates,timestamp ,CarId – Amehiny Dec 18 '14 at 10:41
  • its similar to this prb: http://stackoverflow.com/questions/15035143/how-to-calculate-distance-between-multiple-points-in-sql-server. But I have the coordinates in my database – Amehiny Dec 18 '14 at 10:43

0 Answers0