Subject | Re: [firebird-support] Select using user defined aggregate function |
---|---|
Author | Dmitry Yemanov |
Post date | 2007-08-07T14:53:56Z |
vojtech.vild wrote:
from unit
join unit_flag on unit.id = unit_flag.unitId
join flag on flag.id = unit_flag.flagId
group by 1, 2
select unit.id, unit.name, could(unit_flag.flagId)
from unit
join unit_flag on unit.id = unit_flag.unitId
group by 1, 2
Dmitry
>Only in FB 2.1.
> CREATE TABLE UNIT (id integer PRIMARY KEY, name varchar(64) UNIQUE);
> CREATE TABLE FLAG (id integer PRIMARY KEY, name varchar(64) UNIQUE);
> CREATE TABLE UNIT_FLAG (unitId integer REFERENCES unit, flagId integer
> REFERENCES flag, PRIMARY KEY (unitId, flagId));
>
> I want in one select show flags for every unit separeted with the
> colon. Is it possible?
> | id | name | flags |select unit.id, unit.name, list(flag.name)
> |----|--------|---------------|
> | 1 |pikeman | spear, armour |
> | 2 |wolf | quick |
from unit
join unit_flag on unit.id = unit_flag.unitId
join flag on flag.id = unit_flag.flagId
group by 1, 2
> Very similar problem is how many flags has every unit:For any FB version:
select unit.id, unit.name, could(unit_flag.flagId)
from unit
join unit_flag on unit.id = unit_flag.unitId
group by 1, 2
> So I am thinking about write own aggregate function.Not, it's not possible.
> Is it possible to define own aggregate function in Firebird?
Dmitry