Partition the result set and create multiple arrays

The following is more generic approach. It does any number of StepNo’s

SELECT OBJECT "StepNo_"||TOSTRING(v[0].stepNo):v FOR v IN (SELECT RAW ARRAY_AGG(d) FROM  default d
                           WHERE d.stepNo IS NOT NULL
                           GROUP by d.stepNo) END;
1 Like