>>I will have the rep's total calltime In what format will you have the total calltime? Here is one possible solution where totalcalltime and range values are all in Hours:set nocount ondeclare @rates table (lowRange int, hiRange int, rate money)insert @rates select 0,20,6.15 unionselect 21, 2160, 8.50 unionselect 2161, 10000000, 10 declare @reps table (repid int, totalCallTime int)insert @repsselect 1, 11 unionselect 2, 18 unionselect 3, 45 unionselect 4, 6002 unionselect 5, 2160select repid ,ratefrom @reps ajoin @rates b on a.totalcalltime between b.lowRange and b.hiRange
Be One with the OptimizerTG