Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 returning lowest and highest value of a consecutive set of numbers

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-07-29 : 21:47:54
Clint writes "I have a table that contains "Road Numbers", and many "Road Numbers" relate to an "ID". The table is like this:
[Road Number][ID]
[100] [1]
[101] [1]
[102] [1]
[103] [1]
[107] [1]
[108] [1]
[109] [1]
[110] [1]
[104] [2]
[105] [2]
[106] [2]
[111] [2]
[112] [2]
[113] [3]
[114] [3]
[115] [3]


What I would like to return is a result set like this:
[ID][Lowest Road Number][Highest Road Number]
[1] [100] [103]
[1] [107] [110]
[2] [104] [106]
[2] [111] [112]
[3] [113] [115]


The only way that I have been able to do this is with a loop, and it is very slow. A SQL solution would be nice"
   

- Advertisement -