I continue a series on window functions in SQL Server:
As of SQL Server 2019, there is only one ordered set function:
STRING_AGG()
. I likeSTRING_AGG()
a lot, especially because it means my days of needing to explain theSTUFF()
+FOR XML PATH
trick to concatenate values together in SQL Server are numbered.
STRING_AGG()
is interesting in that we categorize it as a window function and yet it violates my first rule of window functions: there isn’t anOVER()
clause. Instead, it accepts but does not require aWITHIN GROUP()
clause. Let’s see it in action.
Click through for a look at that, as well as a little hint that maybe we’ve seen ordered set functions before in a different guise.