briangriffin
Programmer
I have a table of surgical procedures:
Account [tab] ProcedureCode
999 [tab][tab][tab]X1235
And a table used to cross reference procedures to billing codes:
RangeStart [tab][tab][tab] RangeEnd
X1234 [tab][tab][tab] [tab][tab][tab] X1345
X2345 [tab][tab][tab] [tab][tab][tab] X2467
I need to return all the accounts with ProcedureCodes within the ranges in the table. I thought this would work:
Select
a.Account,
a.ProcedureCode
from SurgicalProcedures a inner join CodeLookup b
on a.ProcedureCode >= b.RangeStart
and a.ProcedureCode <= b.RangeEnd
That doesn't give me a true cartesian product, but the record count is grossly inflated with records where the code is nowhere near the ranges. How can I get the desired result?
TIA
Account [tab] ProcedureCode
999 [tab][tab][tab]X1235
And a table used to cross reference procedures to billing codes:
RangeStart [tab][tab][tab] RangeEnd
X1234 [tab][tab][tab] [tab][tab][tab] X1345
X2345 [tab][tab][tab] [tab][tab][tab] X2467
I need to return all the accounts with ProcedureCodes within the ranges in the table. I thought this would work:
Select
a.Account,
a.ProcedureCode
from SurgicalProcedures a inner join CodeLookup b
on a.ProcedureCode >= b.RangeStart
and a.ProcedureCode <= b.RangeEnd
That doesn't give me a true cartesian product, but the record count is grossly inflated with records where the code is nowhere near the ranges. How can I get the desired result?
TIA