I'm looking for a query to get the following output:
Id Number
-- ------
1 241100
2 241110
2 241111
2 241112
2 241113
2 241114
2 241115
Table strucutre:
Id Number From To
-- ------ ---- ----
1 241100 NULL NULL
2 241110 111 115
Rows without a from/to range has to return the number. The other ones have to return the number followed by SUBSTRING(Number, 1, 3) + <from/to range>
One possible solution would be using while-loops. But thats not the way I'd prefer. And it's quite slow. And there's no way to change the data structure. We query data from a third party supplier.
On application site I've a (very small) list of numbers such as '241113', '241000', ... and need to know to which id this number is assigned to.
The query I will use to get a result is:
SELECT Id, Number FROM MyView WHERE Number IN ('241113', '241000')