Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I understand correctly, you're trying to save this new data about wet periods and dry periods back into the rows, to save for later use? </p> <p>I assume this is so that as each new day is added, it's easy to re-calculate .... or because the data is moving onto somewhere else? </p> <p>Anyway, if this is the case, then one way you could go about it is by having two new columns: 'wet_count" and "dry_count". Count through each row. If the row's wet/dry value matches that of the day before, then increment that value. If it doesn't, zero the values and set the appropriate one to the new value. As such:</p> <pre><code>day rainfall wet_count dry_count Feb 1 1 1 0 Feb 2 0.5 2 0 Feb 3 0.75 3 0 Feb 4 0 0 1 Feb 5 0 0 2 Feb 6 0 0 3 Feb 7 0.5 1 0 Feb 8 1.25 2 0 Feb 9 1.5 3 0 Feb 10 3.5 4 0 Feb 11 4.5 5 0 </code></pre> <p>Then you can simply pull the max value from the table, go back to the first 1 in that column prior to that date, and you have your 'largest period' and 'when it started'.</p> <p>On each new day's data, you only need to calculate versus the previous day, then run two very simple database searches to get the new 'largest period'.</p> <p>More specifically - you pull the distinct values of 'wet_count', ordered descending, and take only the first answer. You do a select on the database where all wet_count = that max, or 1. and you get the number of wet periods that match that particular value, plus the possible start dates. The 1 immediately prior to the max value will be the start date.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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