3

I have this table:

|    A    |  B  |
|---------|-----|
| grocery | $10 |
| clothes | $40 |
| grocery | $19 |

etc.

So I'd like to have a column with an aggregation of the categories like grocery and clothes with the total expenses, what in SQL would be a JOIN with the aggregate function SUM()

How can I achieve this?

2

This is what I think you're looking for:

Formula

=QUERY(DATA!B1:C3;"SELECT B, SUM(C) GROUP BY B label B 'Type', SUM(C) 'Sum'")

Explained

Column C is aggregated by column B through a summation. Labels are added. In this particular case, the usage of JOIN in an SQL statement isn't applicable, since the aggregation is done on one table.

Screenshots

Data:
data

Result
result

Example

I've created an example file for you: Sum Aggregate

  • 1
    I changed the label from 'Type' to 'Thank you very much sir! it worked like a charm! :D' – Petruza Oct 30 '13 at 21:53
0

There is a general Pivot table tool included in the Spreadsheet application. You find it under Data → Pivot table report.

This tool is typically good for _give me the sum of B (price) partitioned per A (category)"

This would be a pivot table with row of A and value of B, show sum() which can be built using the pivot table tool.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.