Skip to content
Advertisement

How to select multiple ranges seperated by group id

I need to create a comma delimited list of values for each group id in a table and fill in any missing values but I’m not quite sure how to proceed. I’m using Server 2016.

my table:

expected output:

Advertisement

Answer

Here’s an alternate way. Create a function that takes start and end numbers and generates missing numbers.

Once that is done, write this SQL:

Result

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement