Skip to content
Advertisement

Generate range of numbers between two numbers

I could use some help with a query to expand a CSV I’m working with, but I don’t know the best way to handle the query. My data looks like this:

I need to generate a range between the beginning ID and ending ID, and then duplicate the color and dwelling entries for that range. This is what I’m hoping to achieve:

I’ve see other methods that allow me to generate a single range of numbers, but nothing that pulls the beginning and ending numbers from the columns in a table.

Anyway help is greatly appreciated!!

Storm

Advertisement

Answer

You could do it with a recursive CTE like this

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