Note that there are some explanatory texts on larger screens.

plurals
  1. POFind Min value in row from Dynamic Datatable
    text
    copied!<p>So I have 2 datatables, The 1st datatable is a traditional datatable which gets its data from certain sql statements.</p> <p>Datatable 1:</p> <pre><code> | user_point | | lat | | lng | | radius | -------------------------------------------------------------- | userpoint0 | | 43.702943 | | -79.37478 | | 3.10685596 | | userpoint1 | | 43.672655 | | -79.479837 | | 4.970969536 | </code></pre> <p>However, the certain columns are dynamically generated in Datatable 2 based on the number of userpoints in Datatable 1.</p> <pre><code> | id | | lat | | lng | | DistanceFromUserpoint0 | | DistanceFromUserpoint1 | ------------------------------------------------------------------------------------------------------------- | 23184 | | 43.6495246887207 | | -79.4244003295898 | | 4.4464409231533 | | 3.19880848195014 | | 37957 | | 43.6372413635254 | | -79.4151458740234 | | 4.96760996486758 | | 4.05524888969018 | | 37965 | | 43.636589050293 | | -79.4169921875 | | 5.04670564187353 | | 4.00990129127938 | | 60467 | | 43.735538482666 | | -79.4437942504883 | | 4.11692339031897 | | 4.70303114025665 | | 60475 | | 43.735538482666 | | -79.4437942504883 | | 4.11692339031897 | | 4.70303114025665 | | 65615 | | 43.7292861938477 | | -79.4317932128906 | | 3.37923630122185 | | 4.59015403452972 | | 65623 | | 43.7292861938477 | | -79.4317932128906 | | 3.37923630122185 | | 4.59015403452972 | | 3196486 | | 43.6624603271484 | | -79.4242172241211 | | 3.7316961595166 | | 2.86768157143755 | | 3196494 | | 43.6624603271484 | | -79.4242172241211 | | 3.7316961595166 | | 2.86768157143755 | | 5756393 | | 43.719165802002 | | -79.4295654296875 | | 2.95683309139676 | | 4.07847187106957 | | 5756922 | | 43.719165802002 | | -79.4295654296875 | | 2.95683309139676 | | 4.07847187106957 | | 5756956 | | 43.719165802002 | | -79.4295654296875 | | 2.95683309139676 | | 4.07847187106957 | | 5756991 | | 43.719165802002 | | -79.4295654296875 | | 2.95683309139676 | | 4.07847187106957 | | 5757096 | | 43.719165802002 | | -79.4295654296875 | | 2.95683309139676 | | 4.07847187106957 | | 5757134 | | 43.719165802002 | | -79.4295654296875 | | 2.95683309139676 | | 4.07847187106957 | </code></pre> <p>Now I will add a new column at the end of datatable 2 called the <code>Closest_userpoint</code> which will store the value of the distance which is the closest userpoint for that row.</p> <p>So now my question is how to I find the the smallest/min value for that row, which has columns that are dynamically generated(which means there can be any number of userpoints from none to 100). I am looking for a simplest and most efficient answer, Thank you</p> <p><strong>EDIT:</strong></p> <p>Here is my code for how the dynamic columns are created, However I am stuck on figuring out the logic to fill the closestUserpoint Column with min value for that row based on the distancefromuserpoints</p> <p><strong>EDIT 2:</strong></p> <p><strong>BONUS QUESTION:</strong></p> <p>Finally I want to determine if that closest Point/Min value falls within the raidus for that userpoint which it is closest.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload