← avg operator page · aggregate/avg/ds_having/one_measure
pandas ✅ · DuckDB ✅
avg with the having of Two measures, on a single-measure operand: the shared input without Me_2.
Aggregate invocation: "only groups for which havingCondition evaluates to true appear in the result"; the page does not restrict having to single-measure operands.
avg ( Me_1 ) > 3 holds for B only, which is kept with Me_1 = 6.
DS_r := avg ( DS_1 group by Id_1 having avg ( Me_1 ) > 3 );
| Id_1 | Id_2 | Me_1 |
|---|---|---|
| A | 2020Q1 | 3 |
| A | 2020Q2 | 1 |
| A | 2021Q1 | 5 |
| A | 2021Q2 | 1 |
| B | 2020Q1 | 4 |
| B | 2020Q2 | 8 |
{
"datasets": [
{
"name": "DS_1",
"DataStructure": [
{"name": "Id_1", "type": "String", "role": "Identifier", "nullable": false},
{"name": "Id_2", "type": "Time_Period", "role": "Identifier", "nullable": false},
{"name": "Me_1", "type": "Number", "role": "Measure", "nullable": true}
]
}
]
}
| Id_1 | Me_1 |
|---|---|
| B | 6 |
{
"datasets": [
{
"name": "DS_r",
"DataStructure": [
{"name": "Id_1", "type": "String", "role": "Identifier"},
{"name": "Me_1", "type": "Number", "role": "Measure"}
]
}
]
}