I need to create a two-dimensional array from a list of values. E. g. we have a table with one field called 'Number', and there are 15 records from 1 to 15 in it.
SELECT array_agg(Number) from someTable;
array_agg
-------------------------------------
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}
(1 row)
How can I aggregate them with SELECT-statement to get a two-dimensional array with fixed width (for example, 4) and unlimited height?
{
{1,2,3,4},
{5,6,7,8},
{9,10,11,12},
{13,14,15}
}
Thanks.