---
title: "Zip Aggregate Function"
description: "Group function which combines the binary documents of a group into one ZIP archive."
language: en
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/aggregate-functions/zip-aggregate-function
original: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/aggregate-functions/zip-aggregate-function
updated: 2026-08-09T00:00:00Z
license: https://documentation.invantive.eu/en/
---

## Syntax
```mermaid
%%{init: {
  'theme': 'base',
  'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
  'themeVariables': {
    'fontSize': '11px',
    'fontFamily': 'Arial'
  }
}}%%
flowchart LR
    zipAggregateFunction_start((START))
    zipAggregateFunction_start --> zipAggregateFunction_0_0[ZIP]:::quoted
    zipAggregateFunction_0_0 --> zipAggregateFunction_0_1["("]:::quoted
    zipAggregateFunction_0_1 --> zipAggregateFunction_0_2[expressionList]
    zipAggregateFunction_0_2 --> zipAggregateFunction_0_3[")"]:::quoted
    zipAggregateFunction_0_3 --> zipAggregateFunction_end((END))
```

## Purpose
Group function which combines the binary documents of a group into one ZIP archive. The first expression provides the binary contents (`blob`) of each document; the second expression provides the file name of the document within the archive. Occurrences of `null` contents are skipped; when solely `null` contents are present, the outcome is `null`.

Returns: the ZIP archive as `blob`.

## Examples
The following example combines the invoice PDF documents of all customers into one ZIP archive, for instance to hand over to an auditor; the outcome is one `blob` containing a file per invoice:
```sql
select zip(ivc.pdf_document, ivc.invoice_number || '.pdf') invoices_archive
from   invoices ivc
```
The following example combines the invoice PDF documents per customer into one ZIP archive per customer, for instance to send each customer a copy of the open invoices, and names each archive after the customer:
```sql
select ivc.customer_name
,      zip(ivc.pdf_document, ivc.invoice_number || '.pdf') invoices_archive
from   invoices ivc
group
by     ivc.customer_name
```