# Table decimal group sum

`table-decimal-group-sum` · version 1.0.0 · CSV & tables · free, no key needed

Group table rows by string keys and compute exact decimal sum results with deterministic ordering.

**Use when you need to: group table decimal sum · exact decimal sum by category · aggregate decimal sum by composite key.**

## Decide before calling

Read the [versioned contract](/v1/tools/table-decimal-group-sum/versions/1.0.0) and the supported scope below. Reuse `table-decimal-group-sum@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `table-decimal-group-sum@1.0.0` for group table decimal sum. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- group table decimal sum
- exact decimal sum by category
- aggregate decimal sum by composite key
- SQL style grouped decimal sum
- avoid floating point drift in grouped sum
- deterministic table sum aggregation

## Not supported

- ungrouped scalar array statistics
- binary floating-point inputs
- streaming or window aggregates

## Behavior

- Rows are assigned to composite groups by the exact sequence of group_by string values; groups are emitted in first-seen row order.
- Every group key column must exist and contain a well-formed string; value_column must exist and contain a canonical decimal string or null.
- null_policy ignore excludes null values and yields null aggregate fields when a group has no non-null values; error rejects the first null value.
- Decimal inputs use optional minus, canonical integer syntax, and optional fractional digits; results remove trailing fractional zeros and normalize signed zero to 0.
- Sum is exact after aligning decimal scales and may contain at most 105 digits.

## Input

- `rows` (array of object, required): max items 10000
- `group_by` (array of string, required): min items 1; max items 8; each min length 1; each max length 64
- `value_column` (string, required): min length 1; max length 64
- `null_policy` (one of "ignore", "error", required)

## Output

- `groups` (array of object, required): max items 10000
- `standard_version` (constant "IBM General Decimal Arithmetic Specification 1.70; SQL:2016", required)

## Limits

- max input bytes: 2097152
- max rows: 10000
- max columns per row: 32
- max group columns: 8
- max column name bytes: 64
- max cell bytes: 256
- max decimal digits: 100
- max decimal scale: 50
- max groups: 10000
- max output bytes: 2097152

## Example

Request input:

```json
{
  "rows": [
    {
      "g": "A",
      "v": "1"
    },
    {
      "g": "A",
      "v": "2"
    }
  ],
  "group_by": [
    "g"
  ],
  "value_column": "v",
  "null_policy": "ignore"
}
```

Response:

```json
{
  "result": {
    "groups": [
      {
        "key_values": [
          "A"
        ],
        "row_count": 2,
        "value_count": 2,
        "sum": "3"
      }
    ],
    "standard_version": "IBM General Decimal Arithmetic Specification 1.70; SQL:2016"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "table-decimal-group-sum",
  "version": "1.0.0",
  "input": {
    "rows": [
      {
        "g": "A",
        "v": "1"
      },
      {
        "g": "A",
        "v": "2"
      }
    ],
    "group_by": [
      "g"
    ],
    "value_column": "v",
    "null_policy": "ignore"
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/table-decimal-group-sum/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"rows":[{"g":"A","v":"1"},{"g":"A","v":"2"}],"group_by":["g"],"value_column":"v","null_policy":"ignore"}'
```

The machine-readable contract is at [/v1/tools/table-decimal-group-sum/versions/1.0.0](/v1/tools/table-decimal-group-sum/versions/1.0.0).

### CLI

```sh
node cli.mjs run table-decimal-group-sum 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Table decimal group average](/tools/table-decimal-group-average): Group table rows by string keys and compute exact decimal average results with deterministic ordering.
- [Table decimal group extrema](/tools/table-decimal-group-extrema): Group table rows by string keys and compute exact decimal extrema results with deterministic ordering.
- [Table decimal group count](/tools/table-decimal-group-count): Count rows by exact string-valued dimensions with stable, bounded grouping output.
- [Table decimal group cube](/tools/table-decimal-group-cube): Sum exact decimal strings over deterministic SQL CUBE grouping sets with explicit subtotal markers.
- [Table decimal group rollup](/tools/table-decimal-group-rollup): Sum exact decimal strings over deterministic SQL ROLLUP grouping sets with explicit subtotal markers.
- [Table groupby check](/tools/table-groupby-check): Check claimed GROUP BY rows (group keys and aggregate values) over JSON rows; returns the first wrong group or value.
