View Full Version : Calculate connected links lengths for nodes

July 16, 2014, 03:10 AM
I am trying to calculate main lengths for assigning leakage on nodes as 'leakage by main length' values. The query below does calculate main lengths for the nodes connected to more than one link, but it returns null values for the end nodes (nodes connected to only one link). Is there a better way of doing this?
SELECT node_id, SUM(ds_links.length) + SUM(us_links.length))


October 7, 2014, 01:27 PM
I am not sure if it is too late to reply to this but the query below will make it work, I have chosen user_number_1 but you can use any unused user number column:

SET user_number_1 = SUM(ds_links.length) + SUM(us_links.length) WHERE SUM(ds_links.length) > 0 AND SUM(us_links.length) > 0;
SET user_number_1 = SUM(ds_links.length) WHERE SUM(us_links.length) = "";
SET user_number_1 = SUM(us_links.length) WHERE SUM(ds_links.length) = "";
SELECT node_id AS 'Node ID', user_number_1 AS 'Main Length';