title: How to select max value by condition and then compare it with others?
body: <p>I have a backup set that is described by json. Sample is below.
  I want to count how much increment backups were added since the last full backup.
  I try to select max timestamp of the record with type &quot;full&quot; so after that i will count how much records with type &quot;incr&quot; has the bigger timestamp.</p>
  <pre class="lang-json prettyprint-override"><code>{
    &quot;archive&quot;: [
      {
        &quot;database&quot;: {
          &quot;id&quot;: 1
        },
        &quot;id&quot;: &quot;11-1&quot;,
        &quot;max&quot;: &quot;0000000A000018B90000006A&quot;,
        &quot;min&quot;: &quot;0000000A0000167D000000C7&quot;
      }
    ],
    &quot;backup&quot;: [
      {
        &quot;archive&quot;: {
          &quot;start&quot;: &quot;0000000A0000181600000030&quot;,
          &quot;stop&quot;: &quot;0000000A0000181C00000083&quot;
        },
        &quot;backrest&quot;: {
          &quot;format&quot;: 5,
          &quot;version&quot;: &quot;2.28&quot;
        },
        &quot;database&quot;: {
          &quot;id&quot;: 1
        },
        &quot;info&quot;: {
          &quot;delta&quot;: 417875448942,
          &quot;repository&quot;: {
            &quot;delta&quot;: 67466720725,
            &quot;size&quot;: 67466720725
          },
          &quot;size&quot;: 417875448942
        },
        &quot;label&quot;: &quot;20201213-200009F&quot;,
        &quot;prior&quot;: null,
        &quot;reference&quot;: null,
        &quot;timestamp&quot;: {
          &quot;start&quot;: 1607878809,
          &quot;stop&quot;: 1607896232
        },
        &quot;type&quot;: &quot;full&quot;
      },
      {
        &quot;archive&quot;: {
          &quot;start&quot;: &quot;0000000A0000182900000065&quot;,
          &quot;stop&quot;: &quot;0000000A0000182F00000069&quot;
        },
        &quot;backrest&quot;: {
          &quot;format&quot;: 5,
          &quot;version&quot;: &quot;2.28&quot;
        },
        &quot;database&quot;: {
          &quot;id&quot;: 1
        },
        &quot;info&quot;: {
          &quot;delta&quot;: 122520170241,
          &quot;repository&quot;: {
            &quot;delta&quot;: 19316550760,
            &quot;size&quot;: 67786280115
          },
          &quot;size&quot;: 416998156028
        },
        &quot;label&quot;: &quot;20201213-200009F_20201214-200009I&quot;,
        &quot;prior&quot;: &quot;20201213-200009F&quot;,
        &quot;reference&quot;: [
          &quot;20201213-200009F&quot;
        ],
        &quot;timestamp&quot;: {
          &quot;start&quot;: 1607965209,
          &quot;stop&quot;: 1607974161
        },
        &quot;type&quot;: &quot;incr&quot;
      },
      {
        &quot;archive&quot;: {
          &quot;start&quot;: &quot;0000000A0000185B000000DD&quot;,
          &quot;stop&quot;: &quot;0000000A0000185B000000F4&quot;
        },
        &quot;backrest&quot;: {
          &quot;format&quot;: 5,
          &quot;version&quot;: &quot;2.28&quot;
        },
        &quot;database&quot;: {
          &quot;id&quot;: 1
        },
        &quot;info&quot;: {
          &quot;delta&quot;: 126982395984,
          &quot;repository&quot;: {
            &quot;delta&quot;: 19541379733,
            &quot;size&quot;: 67993072945
          },
          &quot;size&quot;: 421395153101
        },
        &quot;label&quot;: &quot;20201213-200009F_20201217-200105I&quot;,
        &quot;prior&quot;: &quot;20201213-200009F_20201214-200009I&quot;,
        &quot;reference&quot;: [
          &quot;20201213-200009F&quot;,
          &quot;20201213-200009F_20201214-200009I&quot;
        ],
        &quot;timestamp&quot;: {
          &quot;start&quot;: 1608224465,
          &quot;stop&quot;: 1608233408
        },
        &quot;type&quot;: &quot;incr&quot;
      }
    ]
  }
  </code></pre>
  <p>I tried to complete first part by this command but it says that &quot;number (1607896232) and number (1607896232) cannot be iterated over&quot;</p>
  <pre><code>.[0] |.backup[] | select(.type==&quot;full&quot;).timestamp.stop|max
  </code></pre>
  <p>I tried sort_by but has no luck. So what am I doing wrong here?</p>