Batching up data into groups of n rows

Поиск
Список
Период
Сортировка
От Andy Chambers
Тема Batching up data into groups of n rows
Дата
Msg-id CAAfW55pWbVNijXqjacT4FYjV8w_Srt+MPsp0ApY7W9Xh_LHKyg@mail.gmail.com
обсуждение исходный текст
Ответы Re: Batching up data into groups of n rows
Список pgsql-general
Hi,

I have a need to write a query that batches up rows of a table into
groups of n records.  I feel like this should be possible using the
existing window functions but I can't figure out how to do it from the
examples.

So I have some table, let's say

create table addresses (
  line_1 text,
  line_2 text,
  city text,
  state text,
  zip text);

...and I want to select the data from that table, adding a "group_id"
column, and a "record_id" column.  The "group_id" would start at 1,
and increment by 1 every 100 rows, and the "record_id" would increment
by 1 every row, but restart at 1 for each new group_id.

Thanks,
Andy

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

Предыдущее
От: Alban Hertroys
Дата:
Сообщение: Re: Does postgresql 9.0.4 use index on PREFIX%SUFFIX queries?
Следующее
От: hamann.w@t-online.de
Дата:
Сообщение: Re: looking for a faster way to do that