CHAPTER 3
Ordered Set Functions
Have you ever needed to concatenate elements of a group into one string based on some order? That’s a scenario that an ordered set function could help address. An ordered set function is a type of aggregate function. What distinguishes it from a general set function (like SUM, MIN, MAX, and so on) is that there’s ordering relevance to the calculation, such as the order in which you want to concatenate the elements.
In this chapter, I will discuss ordered set functions and the kinds of solutions they help with. At the date of this writing, the only ordered set function that SQL Server supports is STRING_AGG for string concatenation. This function was added in SQL Server 2017. There are additional ordered set functions ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access