Re: multiple paramters in aggregate function

Поиск
Список
Период
Сортировка
От Sim Zacks
Тема Re: multiple paramters in aggregate function
Дата
Msg-id 4A8D0200.5000807@compulab.co.il
обсуждение исходный текст
Ответ на Re: multiple paramters in aggregate function  (Sim Zacks <sim@compulab.co.il>)
Список pgsql-general
> My query contains select ..,
> sum_unitvalues(qty,unitid),sum_units(unitid),...
> then the units returned do not have to be known in advance, which is
> important in this specific project.
>
To give an example of my required result set:

unitid
1 = mm
2 = inch
3 = ft
4 = gram

create table test(id serial primary key, qty numeric(12,4), unitid int);
insert into test(qty,unitid)
 values(100,2),(200,2),(5,3),(20,1),(800,4)

select sum_unitvalues(qty,unitid) as qty, sum_units(unitid) as unitid
from test where unitid<>4;

qty       |  unitid
----------------------------
 9124   | 1

select sum_unitvalues(qty,unitid) as qty, sum_units(unitid) as unitid
from test  where unitid not in (1,4);

qty       |  unitid
----------------------------
  360    | 2

select sum_unitvalues(qty,unitid) as qty, sum_units(unitid) as unitid
from test;
qty       |  unitid
----------------------------
NULL  | NULL


В списке pgsql-general по дате отправления:

Предыдущее
От: Sim Zacks
Дата:
Сообщение: Re: multiple paramters in aggregate function
Следующее
От: Kalai R
Дата:
Сообщение: Field's position in Table