View Single Post
  #1 (permalink)  
Old 04-01-2008, 09:19 PM
larry@portcommodore.com
 
Posts: n/a
Default Looking up a row of data based on amount and date

I'm trying to look up a value on a lookup table based on an amount and
a date

Now the "lookup-tables" change from period to period so the main
"tables" record has a start and end date and id

SELECT table_id FROM tables
$date >= startdate AND $date <= enddate

next I need to select the right row from the "tablelist" table (which
has all the lookup data) based on a column item that is the maximum
value but less than or equal to the amount


SELECT * FROM tablelist
WHERE table_id = $table_id
AND amount = SELECT MAX(amount) WHERE amount <= $testamount

I think I'm close, how would I roll it all into one?
Reply With Quote