title: how to get a max per group and subgroup using jq
body: <p>jq is an amazing tool and it does a lot.
  as input I have</p>
  <pre><code>[
    {
      &quot;backup&quot;: [
        {
          &quot;timestamp&quot;: { &quot;start&quot;: 1642144383, &quot;stop&quot;: 1642144386 },
          &quot;info&quot;: {  &quot;size&quot;: 1200934840},
          &quot;type&quot;: &quot;full&quot;
        },
        {
          &quot;timestamp&quot;: {&quot;start&quot;: 1642144388, &quot;stop&quot;:  1642144392 },
          &quot;info&quot;: { &quot;size&quot;: 1168586300
          },
          &quot;type&quot;: &quot;incr&quot;
        },
        {
          &quot;timestamp&quot;: {&quot;start&quot;: 1642145388, &quot;stop&quot;:  1642145392 },
          &quot;info&quot;: { &quot;size&quot;: 1168586330
          },
          &quot;type&quot;: &quot;incr&quot;
        }
      ],
      &quot;name&quot;: &quot;dbname1&quot;
    },
    {
      &quot;backup&quot;: [
        {
          &quot;timestamp&quot;: { &quot;start&quot;: 1642144383, &quot;stop&quot;: 1642144386 },
          &quot;info&quot;: {  &quot;size&quot;: 1200934840},
          &quot;type&quot;: &quot;full&quot;
        },
        {
          &quot;timestamp&quot;: {&quot;start&quot;: 1642144388, &quot;stop&quot;:  1642144392 },
          &quot;info&quot;: { &quot;size&quot;: 1168586300
          },
          &quot;type&quot;: &quot;incr&quot;
        }
      ],
      &quot;name&quot;: &quot;dbname2&quot;
    }
  ]
  </code></pre>
  <p>and using</p>
  <pre><code>jq 'map([.backup[] + {name}] | max_by(.timestamp.stop))'
  </code></pre>
  <p>I get the latest timestamp.stop for a name. How should I change this to get the latest timestamp.stop for a name and group?
  in SQL this would be something like max(.timestamp.stop) group by .name,.type
  Hoping for output like:</p>
  <pre><code>[
    {
      &quot;timestamp&quot;: {
        &quot;start&quot;: 1642144383,
        &quot;stop&quot;: 1642144386
      },
      &quot;info&quot;: {
        &quot;size&quot;: 1200934840
      },
      &quot;type&quot;: &quot;full&quot;,
      &quot;name&quot;: &quot;dbname1&quot;
    },
    {
      &quot;timestamp&quot;: {
        &quot;start&quot;: 1642145388,
        &quot;stop&quot;: 1642145392
      },
      &quot;info&quot;: {
        &quot;size&quot;: 1168586330
      },
      &quot;type&quot;: &quot;incr&quot;,
      &quot;name&quot;: &quot;dbname1&quot;
    },
    {
      &quot;timestamp&quot;: {
        &quot;start&quot;: 1642144383,
        &quot;stop&quot;: 1642144386
      },
      &quot;info&quot;: {
        &quot;size&quot;: 1200934840
      },
      &quot;type&quot;: &quot;full&quot;,
      &quot;name&quot;: &quot;dbname2&quot;
    },
    {
      &quot;timestamp&quot;: {
        &quot;start&quot;: 1642144388,
        &quot;stop&quot;: 1642144392
      },
      &quot;info&quot;: {
        &quot;size&quot;: 1168586300
      },
      &quot;type&quot;: &quot;incr&quot;,
      &quot;name&quot;: &quot;dbname2&quot;
    }
  ]
  </code></pre>