Re: query

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: query
Дата
Msg-id 20040119052013.GA19053@wolff.to
обсуждение исходный текст
Ответ на query  (Ankur Arora <"Ankur Arora"@clear.net.nz>)
Список pgsql-novice
On Sun, Jan 18, 2004 at 00:02:42 +1300,
  Ankur Arora <"Ankur Arora"@clear.net.nz> wrote:
> hello there
> i have a problem
> i want to know the query for finding out aggregate
>
> eg. i have a column named sum in table xyz
>
> sum
> ----
> 2
> 4
> 7
> 5
>
>
> i want a sql query that will give me another column alongwith this column as
> aggregate
>
> sum     aggregate
> -----
> 2       2
> 4    6
> 7    13
> 5    18
>
>
> if u could help me i will be obliged as i really need it on urgent basis

Its possible to do something like this with subqueries as long as there
is some way (e.g. additional columns) to order the table.

Then you could do something like:

select "sum", (select sum("sum") from xyz b where b.id <= a.id) from xyz a
  order by id;
This assumes there is a column named id which can be used to order the data.

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: installing postgre
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Discarding UNIQUE temporarily?