Each row of a_time b_time, c_time, d_time and e_time sorting, sorting result in Reltestseq column,
For example: SAM if a_time & lt; B_time=& lt;=c_time & lt;=d_time & lt;=e_time is put in Reltestseq column a, b, c, d, e, or 1, 2, 3, 4, 5 can be
CodePudding user response:
With t001 as (Select id, 'A' AS the ORDERS, a_testtime AS test_time FROM testSortseq
UNION ALL
Select id, 'B' AS the ORDERS, B_testtime AS test_time FROM testSortseq
UNION ALL
Select id, 'C' AS the ORDERS, C_testtime AS test_time FROM testSortseq
UNION ALL
Select id, 'D' AS the ORDERS, D_testtime AS test_time FROM testSortseq
UNION ALL
Select id, 'E' AS the ORDERS, E_testtime AS test_time FROM testSortseq
)
Select id, listagg (orders, ', ') within group (order by test_time) seqs from t001 group by id order by id