Re: Group by a range of values
| От | Torsten Grust |
|---|---|
| Тема | Re: Group by a range of values |
| Дата | |
| Msg-id | CAGqkgpgDH7O_AqtPcY91y2TrPaEF4oe-jFwuqXeuFCedgSAUXw@mail.gmail.com обсуждение исходный текст |
| Ответ на | Group by a range of values (Mike Martin <redtux1@gmail.com>) |
| Ответы |
Re: Group by a range of values
|
| Список | pgsql-sql |
Hi,
maybe this does the job already (/ is integer division):
SELECT i, 1 + (i-1) / 3
FROM generate_series(1,10) AS i;
An expression like (i-1) / 3 could, of course, also be used as partitioning criterion in GROUP BY and/or window functions.
Cheers,
—T
On Sat, Aug 1, 2020 at 2:15 PM Mike Martin <redtux1@gmail.com> wrote:
Say I have a field of ints, as for example created by with ordinality or generate_series, is it possible to group by a range? eq1,2,3,4,5,6,7,8,9,10step 3so output is1 12 13 14 25 26 27 38 39 310 4thanks
В списке pgsql-sql по дате отправления: