Calculating a cumulative total

37 views
Skip to first unread message

Thomas Potato

unread,
May 26, 2022, 12:46:16 AM5/26/22
to MapInfo-L
Hi,

I've been attempting to calculate a cumulative distance total for several thousand lines. 

I'm aware I can just take it into excel to calculate this, but would prefer not to.

Select ID, sum(CartesianObjectLen(obj, "m")) "Kilometre_Point" from table1 group by table1.ID into KP_Testing

The above query calculates the segment lengths just fine, but I cannot figure out how to extend this SQL to bring about the running total. By running total/cumulative total, I mean A=A, B=A+B, C=A+B+C, and so forth. Any ideas?

Thanks,
Tom

Martin Hodder

unread,
May 26, 2022, 3:22:09 AM5/26/22
to mapi...@googlegroups.com

Hi Tom,

 

You can try this

 

Select sum(CartesianObjectLen(obj, "m")) "Total_Distance" from table1 into KP_Totlength

 

I don’t think you can get  total length and a length for each segment in one SQL statement in MapInfo.

 

Regards

 

Martin Hodder

Higher Mapping Solutions

www.highermappingsolutions.com

--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mapinfo-l/72d8e5c6-ef94-4375-b182-afbbb476b3f0n%40googlegroups.com.

Thomas Potato

unread,
May 26, 2022, 7:25:57 PM5/26/22
to MapInfo-L
Hi Martin,

As mentioned, I'm after a rolling/cumulative total, you have misunderstood the question.

I'm not sure I can explain it clearer than I already did. Please let me know if there's anything I can further clarify.

Regards,
Tom

Uffe Kousgaard

unread,
May 27, 2022, 1:44:12 AM5/27/22
to mapi...@googlegroups.com
Hi,

What you want isn't possible with MapInfo SQL.
You have to write a mapbasic application, which loops through the records and updates them one by one.

Regards
Uffe Kousgaard
Reply all
Reply to author
Forward
0 new messages