Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2025 11:05 AM
Adding the proper window specification for the "OVER" clause plus DISTINCT helps to achieve some resemblance of STRING_AGG for the simple ascending order:
select distinct
object
,array_join(array_sort(collect_set(property) over (partition by object order by property ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)), ',') as properties
from
(
values
('object 1','C')
,('object 2','F')
,('object 1','B')
,('object 2','E')
,('object 1','A')
,('object 2','D')
) as t(object,property)
order by object| object | properties |
| object 1 | A,B,C |
| object 2 | D,E,F |