> RULE 'co2 Fuel Counter cannot be less than previous day' + > FOR daily_data SUCCEEDS + > WHERE (co2_fuel_counter >= + > (SELECT co2_fuel_counter FROM daily_data t2 + > WHERE t2.gasday = (daily_data.gasday - 1)))
Bill's solution is the most straightforward, but if you want to avoid the non-indexed data access you could also change it to: WHERE (co2_fuel_counter >= (CALL GetFuelCounter(daily_data.gasday-1))) and then define a Stored Procedure called GetFuelCounter. That stored procedure would used the calculated day to SELECT and return the required value, and would do so using an index on GasDay if available. You might also find the Stored Procedure useful in other circumstances where you would otherwise have to recreate the sub select. -- Larry _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com ================================================ TO SEE MESSAGE POSTING GUIDELINES: Send a plain text email to [EMAIL PROTECTED] In the message body, put just two words: INTRO rbase-l ================================================ TO UNSUBSCRIBE: send a plain text email to [EMAIL PROTECTED] In the message body, put just two words: UNSUBSCRIBE rbase-l
