title: How can I get a sum of sums using MongoDB aggregation?
body: <p>I would like to get the total (sum) of the <code>totalHoursForYear</code> value. Here is my current aggregation:</p>
  <pre class="lang-js prettyprint-override"><code>const byYear = await this.workHistoryModel.aggregate([
    {
      $group: {
        _id: '$year',
        history: {
          $push: '$$ROOT'
        },
        totalHoursForYear: {
          $sum: {
            $add: [
              { $multiply: ['$eightHourDays', 8] },
              { $multiply: ['$tenHourDays', 10] },
              { $multiply: ['$twelveHourDays', 12] },
            ]
          }
        },
      }
    },
  ]);
  </code></pre>
  <p>Now I need to get a sum of the <code>totalHoursForYear</code> to get the total for all years. Is this possible? I can't seem to get the syntax correct. When I attempt to add another sum:</p>
  <pre class="lang-js prettyprint-override"><code>$group: {
    ...,
    totalHours: {
      $sum: {
        $add: '$totalHoursForYear'
      },
      $push: '$$ROOT'
    }
  }
  </code></pre>
  <p>I get an error: &quot;The field 'totalHours' must specify one accumulator&quot;</p>