---
title: "DROP AGGREGATE"
url: "https://docs.yugabyte.com/stable/api/ysql/the-sql-language/statements/ddl_drop_aggregate/"
---

# DROP AGGREGATE

Use the DROP AGGREGATE statement to remove an aggregate.

## Synopsis

Use the DROP AGGREGATE statement to remove an aggregate.

## Syntax

- [![Grammar Icon](/icons/file-lines.svg)Grammar](#grammar-1)
- [![Diagram Icon](/icons/diagram.svg)Diagram](#diagram-1)

```output.ebnf
drop_aggregate ::= DROP AGGREGATE [ IF EXISTS ] 
                   { aggregate_name ( aggregate_signature ) } 
                   [ , ... ] [ CASCADE | RESTRICT ]

aggregate_signature ::= * | aggregate_arg [ , ... ]
                        | [ aggregate_arg [ , ... ] ] ORDER BY 
                          aggregate_arg [ , ... ]
```

#### drop\_aggregate

DROPAGGREGATEIFEXISTS,[aggregate\_name](/stable/api/ysql/syntax_resources/grammar_diagrams#aggregate-name)([aggregate\_signature](#aggregate-signature))CASCADERESTRICT

#### aggregate\_signature

\*,[aggregate\_arg](/stable/api/ysql/syntax_resources/grammar_diagrams#aggregate-arg),[aggregate\_arg](/stable/api/ysql/syntax_resources/grammar_diagrams#aggregate-arg)ORDERBY,[aggregate\_arg](/stable/api/ysql/syntax_resources/grammar_diagrams#aggregate-arg)

## Semantics

See the semantics of each option in the [PostgreSQL docs](https://www.postgresql.org/docs/15/sql-dropaggregate.html "PostgreSQL docs").

## Examples

Basic example.

```plpgsql
yugabyte=# CREATE AGGREGATE newcnt(*) (
             sfunc = int8inc,
             stype = int8,
             initcond = '0',
             parallel = safe
           );
yugabyte=# DROP AGGREGATE newcnt(*);
```

IF EXISTS example.

```plpgsql
yugabyte=# DROP AGGREGATE IF EXISTS newcnt(*);
yugabyte=# CREATE AGGREGATE newcnt(*) (
             sfunc = int8inc,
             stype = int8,
             initcond = '0',
             parallel = safe
           );
yugabyte=# DROP AGGREGATE IF EXISTS newcnt(*);
```

CASCADE and RESTRICT example.

```plpgsql
yugabyte=# CREATE AGGREGATE newcnt(*) (
             sfunc = int8inc,
             stype = int8,
             initcond = '0',
             parallel = safe
           );
yugabyte=# CREATE VIEW cascade_view AS
             SELECT newcnt(*) FROM pg_aggregate;
yugabyte=# -- The following should error:
yugabyte=# DROP AGGREGATE newcnt(*) RESTRICT;
yugabyte=# -- The following should error:
yugabyte=# DROP AGGREGATE newcnt(*);
yugabyte=# DROP AGGREGATE newcnt(*) CASCADE;
```

## See also

- [ALTER AGGREGATE](/stable/api/ysql/the-sql-language/statements/ddl_alter_aggregate "ALTER AGGREGATE")
- [CREATE AGGREGATE](/stable/api/ysql/the-sql-language/statements/ddl_create_aggregate "CREATE AGGREGATE")
