Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

most effective way, ranged join.

Status
Not open for further replies.

Jamfool

IS-IT--Management
Apr 10, 2003
484
GB

case id of 1, has been oustanding for 15 days and therefore rate table B must apply a cost of 20. My question is what is the most effective and elegant way to return this rate without using:

Code:
Create Table A
(
CaseID int,
mydate datetime
)
go
insert into a values (1,getdate()-15)
go
Create table B
(
DateLimit int,
cost int
)
go
insert into B values (7,10)
insert into B values (14,20)
insert into B values (21,30)
insert into B values (28,40)
go
select top 1 * from B where DateLimit
>= (select datediff(d,mydate,getdate()) from A)
go
drop Table A
drop Table B
go
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top