# Combine values into one cell per group

Shape / table

A variant of [Summarise by group](https://meridian.online/operations/summarise-by-group).

Join each group's values into one delimited string or one list.

Page: <https://meridian.online/operations/summarise-by-group/combine-values-per-group>

## Status

Runs as a SQL step.

arcform carries it as a `sql:` step today.

## The DuckDB step

combine each group's values into one delimited string or one list

It reads the `orders` table the proofs share. Create it first:

```sql
CREATE TABLE orders AS SELECT * FROM (VALUES
  (1,  'Alice Ng',      'north', DATE '2026-01-03', 120.00, 'widget', 'a|b',   '{"channel":"web","items":[1,2]}'),
  (2,  'alice ng',      'north', DATE '2026-01-05',  80.50, 'gadget', 'b',     '{"channel":"shop","items":[3]}'),
  (3,  'Bob  Okafor',   'south', DATE '2026-01-05', 300.00, 'widget', 'a|c',   '{"channel":"web","items":[4,5,6]}'),
  (4,  'Carla Díaz',    'east',  DATE '2026-01-09',  NULL,  'gizmo',  NULL,    '{"channel":"web","items":[]}'),
  (5,  'Bob Okafor',    'south', DATE '2026-01-12',  45.25, 'gadget', 'c',     '{"channel":"phone","items":[7]}'),
  (6,  'Dev Patel',     'west',  DATE '2026-01-12', 510.00, 'widget', 'a',     '{"channel":"web","items":[8,9]}'),
  (7,  'Carla Diaz',    'east',  DATE '2026-01-20',  99.99, 'gizmo',  'b|c',   '{"channel":"shop","items":[10]}'),
  (8,  'Dev Patel',     'west',  DATE '2026-02-02', 510.00, 'widget', 'a',     '{"channel":"web","items":[8,9]}'),
  (9,  'Eve Larsen',    NULL,    DATE '2026-02-03',  15.00, 'gadget', NULL,    '{"channel":"web","items":[11]}'),
  (10, 'Alice Ng',      'north', DATE '2026-02-10', 220.00, 'gizmo',  'a|b|c', '{"channel":"phone","items":[12,13]}')
) t(order_id, customer, region, order_date, amount, product, tags, meta);
```

Then run the statement:

```sql
CREATE TEMP TABLE result AS
SELECT product,
       string_agg(customer, '; ' ORDER BY order_id) AS customers_text,
       list(order_id ORDER BY order_id) AS order_ids,
       list(DISTINCT customer ORDER BY customer) AS distinct_customers
FROM orders
GROUP BY product;
SELECT * FROM result ORDER BY product;
SELECT CASE WHEN ((SELECT customers_text FROM result WHERE product = 'widget') = 'Alice Ng; Bob  Okafor; Dev Patel; Dev Patel' AND (SELECT order_ids FROM result WHERE product = 'gizmo') = [4, 7, 10] AND (SELECT distinct_customers FROM result WHERE product = 'widget') = ['Alice Ng', 'Bob  Okafor', 'Dev Patel'] AND (SELECT count(*) FROM result) = 3) THEN 'as expected' ELSE error('each product did not come out as one string and one list of its customers and order ids') END AS verdict;
```

It needs nothing installed beyond DuckDB itself.

## What other tools call it

Meridian's classification; an independent blind rating agreed on 95.7% of 324 rows (variant, version 3).

- Apache DataFusion: [`array_agg`](https://datafusion.apache.org/user-guide/sql/aggregate_functions.html) (read 2026-09-27)
- Apache DataFusion: [`string_agg`](https://datafusion.apache.org/user-guide/sql/aggregate_functions.html) (read 2026-09-27)
- dbt-utils: [`listagg`](https://docs.getdbt.com/reference/dbt-jinja-functions/cross-database-macros) (read 2026-09-27)
- DuckDB: [`array_agg`](https://duckdb.org/docs/current/sql/functions/aggregates) (read 2026-09-27)
- DuckDB: [`group_concat`](https://duckdb.org/docs/current/sql/functions/aggregates) (read 2026-09-27)
- DuckDB: [`list`](https://duckdb.org/docs/current/sql/functions/aggregates) (read 2026-09-27)
- DuckDB: [`listagg`](https://duckdb.org/docs/current/sql/functions/aggregates) (read 2026-09-27)
- DuckDB: [`string_agg`](https://duckdb.org/docs/current/sql/functions/aggregates) (read 2026-09-27)
- Duckle: [`Array Aggregate`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/website/docs/components.html) (read 2026-09-25)
- Duckle: [`Collect List`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/website/docs/components.html) (read 2026-09-25)
- Duckle: [`Denormalize`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/website/docs/components.html) (read 2026-09-25)
- EasyMorph: [`Concatenate text`](https://help.easymorph.com/doku.php?id=transformations:concatenatetext) (read 2026-09-27)
- Ibis: [`ArrayCollect`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/reductions.py) (read 2026-09-27)
- Ibis: [`GroupConcat`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/reductions.py) (read 2026-09-27)
- OpenRefine: [`Join multi-valued cells…`](https://openrefine.org/docs/manual/cellediting#join-multi-valued-cells) (read 2026-09-27)
- Polars: [`Expr.str: vertical concatenation (group)`](https://docs.pola.rs/api/python/stable/reference/expressions/string.html) (read 2026-09-27)
- Polars: [`GroupBy.all`](https://docs.pola.rs/api/python/stable/reference/dataframe/group_by.html) (read 2026-09-27)
- Talend: [`tDenormalize`](https://help.qlik.com/talend/en-US/components/8.0/processing/processing-component) (read 2026-09-27)
- Talend: [`tDenormalizeSortedRow`](https://help.qlik.com/talend/en-US/components/8.0/processing/processing-component) (read 2026-09-27)
- Trifacta: [`LIST Function`](https://help.alteryx.com/aac/en/trifacta-classic/wrangle-language/aggregate-functions.html) (read 2026-09-27)
- Trifacta: [`UNIQUE Function`](https://help.alteryx.com/aac/en/trifacta-classic/wrangle-language/aggregate-functions.html) (read 2026-09-27)
