I have some tables from this table and I use this table to get records
string_agg(a2.sampl_no, ', ') as sampl_nosThe
and group by clauses work fine, but I want to have at most 4 sample_no aggregates per row.
Suppose I get
from the databasestring_agg as (0001, 0002, 0003, 0004, 0005, 0006)
In a row, but I want this
(0001, 0002, 0003, 0004) (0006, 0007).
Help me solve this problem.
If you want to do this in the database, you can use
row_number()
to split the records into four groups and then usestring_agg()
: