## In general

In general, this would be a typical task for a pivot table. Starting with the database table shown below, you would define a pivot table to sum the distinct items as follows:

This will give you the following result table:

## Using Gnumeric

Sadly, Gnumeric doesn't support pivot tables yet - so i used LibreOffice to create the screenshots above.

With gnumeric, you could use the DSUM function instead. It will sum the amounts for a given item, but it has the disadvantage that it won't calculate the sums for **all** items automatically; instead, you'll have to insert DSUM functions (and criteria tables) for every distinct item. So, it's quite cumbersome to use this functionality. Here's an example for a gnumeric sheet using the DSUM function:

Cell F2 holds the formula `=dsum(A2:C6;3;A9:C10)`

: `A2:C6`

is the database (on the screenshot: in light green), `3`

is the column to sum up ("Amount"), and `A9:C10`

is the criteria table (light cyan), selecting only rows with item "Apple".

Correspondingly, F3 has `=dsum(A2:C6;3;A13:C14)`

: almost the same, only the second criteria table instead of the first.