sql - Find all INTs BETWEEN multiple ranges -


i'm dealing document parent/child families in discovery tool.

is there easy way return numbers between list of multiple ranges?

i have #temptable 359 rows containing startingbatesnumber, begatt, , endatt

the begatt beginning of bates range, , endatt last document in bates range. here's sample data #temptable:

startingbatesnumber begatt  endatt ctrl00262209    ctrl00262208    ctrl00262209 ctrl00262295    ctrl00262292    ctrl00262295 ctrl00262325    ctrl00262323    ctrl00262326 ctrl00262348    ctrl00262347    ctrl00262362 ctrl00262398    ctrl00262395    ctrl00262399 ctrl00262518    ctrl00262509    ctrl00262597 ctrl00262575    ctrl00262509    ctrl00262597 ctrl00262946    ctrl00262934    ctrl00262955 ctrl00263301    ctrl00263280    ctrl00263304 ctrl00263342    ctrl00263336    ctrl00263360 ctrl00263602    ctrl00263590    ctrl00263614 ctrl00263649    ctrl00263648    ctrl00263649 ctrl00263810    ctrl00263809    ctrl00263810 ctrl00264691    ctrl00264690    ctrl00264691 ctrl00265211    ctrl00265192    ctrl00265320 

this temp table subset of larger table called exporteditems contains same columns. need select every startingbatesnumber between of begatt , endatt items on #temptable. have far is:

select ei.startingbatesnumber exporteditems ei (nolock) ei.startingbatesnumber between #temptable.begatt , #temptable.endatt order ei.startingbatesnumber 

i understand cannot join #temptable that, if added formal join on startingbatesnumber results restricted items on subset , not allow me pull in startingbatesnumbers weren't on list already. find recursive way select startingbatesnumbers between ranges on #temptable.

i know can solve using cursor increment through loop, wondering if there easier way. maybe recursive cte?

i understand cannot join #temptable that

i'm not sure mean. valid sql statement:

select ei.startingbatesnumber exporteditems ei (nolock) join      #temptable tt      on ei.startingbatesnumber between tt.begatt , tt.endatt order ei.startingbatesnumber; 

your statement not correct, because refer table not defined in from clause.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -