title: React store - how to group by and sum
body: <p>In a React store I have a datatable, using redux.  From this one store, I would like to feed additional different datagrids but grouping and summing by different columns.  the below datagrid simply displays the original data.</p>
  <p>For example, I would like second grid to group by pacct, sum by last_price.  In my old non React projects I used linq.  In an old extjs project there was a feature to do this in their store.</p>
  <p>Can someone please assist on how to do this in React?</p>
  <p>this is my table structure...</p>
  <pre><code>export interface TradeData {
    id: number;
    filedate: Date;
    poffic: string;
    pacct: string;
    quantity: number;
    sector: string;
    psdsC1: string;
    name: string;
    bbsymbol: string;
    last_price: number;
    deltasettlement: number;
  }
  </code></pre>
  <p>here is the function I use it...</p>
  <pre><code>export default function Notes() {
    const dispatch = useDispatch();
    const trades = useSelector(
      (state: AppState) =&gt; state.pwData.tradeList
    );
  
    const classes = useStyles();
  
    React.useEffect(() =&gt; {
      const doGetTrades = async () =&gt; {
        const unansweredQuestions = await getTrades();
        dispatch(gotTradesAction(unansweredQuestions));
      };
      doGetTrades();
    }, []);
  
    return (
      &lt;Container&gt;   
        &lt;div style={{ height: 600, width: &quot;100%&quot; }}&gt;
          &lt;DataGrid rows={trades} columns={columns} /&gt;
        &lt;/div&gt;
      &lt;/Container&gt;
    );
  }
  </code></pre>
  <p>UPDATE</p>
  <p>I was able to do a group by (pacct) using reduce, but I can't figure out how to sum 'last_price'.  any help would be greatly appreciated!</p>
  <pre><code>const result = trades.reduce((groupedAccounts, trade) =&gt; {
    const account = trade.pacct;
    if (groupedAccounts[account] == null) groupedAccounts[account] = [];
    groupedAccounts[account].push(trade);
    return groupedAccounts;
  }, {} as Record&lt;string, TradeData[]&gt;);
  </code></pre>