>SELECT SUM(quan_pur) AS Sum24TransUPC, prod_upc FROM pse_trans ; > GROUP BY prod_upc ; > HAVING prod_upc = pse_drug.upc ; > AND trans_dt >= (DATETIME() - 86400) INTO CURSOR TwentyFourHoursQuantUPC >I see you got answered already, but I'd like to point out something else. DATETIME()-86400 is computing per record. That's slower than you might like. The other thing is datetime() moves forward as the time runs.