Skip to content
Advertisement

Is a Union Query needed

I need a little help writing a query. I have this data…

I need to query the data and have an output something like this

The idea here is to select the direction, the LowNum and then the nextNumber. Also when the direction changes to start over. (That’s why I think I need a Union, maybe get the North, then Union the South). Notice too the highest number in each direction doesn’t create a record because there is no higher number. The first set has 8 records, and the query result is only 6.

How can I create a query that will do this? Also this is a 2008 SQL Database so I can use 2008 TSQL. I’m really curious how to do this in SQL. Thanks guys!

Advertisement

Answer

Another possible solution:

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