How do i create an array from a field while applying sorting?
how do I do this in data brick since databricks does not support order by in array_agg? same is possible in Snowflake and(Array agg) or Redshift(listagg).
SELECT ARRAY_AGG(O_ORDERKEY) WITHIN GROUP (ORDER BY timestamp ASC)
FROM orders
+--------------------------------------------------------------+
| ARRAY_AGG(O_ORDERKEY) WITHIN GROUP (ORDER BYtimestamp ASC) |
|--------------------------------------------------------------|
| [ |
| 41445, |
| 55937, |
| 67781, |
| 80550, |
| 95808, |
| 101700, |
| 103136 |
| ] |
+--------------------------------------------------------------+