I need a little help writing a query. I have this data ...
vDir iNumber North 19 North 27 North 29 North 31 South 46 South 49 South 51 South 61
I need to request data and output something like this
vDir iLowNumber iHiNumber North 19 27 North 27 29 North 29 31 South 46 49 South 49 51 South 51 61
The idea here is to select a direction, LowNum, and then nextNumber. Also, when the direction changes to start over. (That's why I think I need a Union, maybe the North, and then the Union South). Also note that the largest number in each direction does not create a record because there is no larger number. The first set has 8 records, and the query result is only 6. How can I create a query that will do this? Any help is appreciated. It is also a SQL 2008 database, so I can use 2008 TSQL. Do I need a cursor here? Is the best solution to use C # and Linq? I'm really curious how to do this in SQL. Thanks guys!
Cheers, ~ ck in San Diego
source share