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