Ok here the complete example (sorry if I wasn’t clear before): 1. I had a table where I insert some data with a datetime and a value CREATE TABLE tableA ( [TimeStamp] datetime, [Value] varchar );
2. Now I have a second table where I want save the lowest time insert in tableA CREATE TABLE tableB ( [LowestTime] time, ); 3. To store the time I wrote a trigger for tableA CREATE TRIGGER tableA _InsertUpdate AFTER INSERT ON tableA begin update tableB set [LowestTime] = CASE WHEN ( [LowestTime] IS NULL ) OR ([LowestTime] > TIME(NEW.TimeStamp)) THEN NEW.[TimeStamp] ELSE [LowestTime] END end; 4. Now I make 2 inserts in tableA (update trigger works because I created a dummy row to work) INSERT into tableA ( [TimeStamp], [Value] ) VALUES ( ‘2011-01-01 01:00:00’, ‘Dump’ ); INSERT into tableA ( [TimeStamp], [Value] ) VALUES ( ‘2011-01-01 02:00:00’, ‘Dump’ ); 5. [LowestTime] should now be ‘01:00:00’ BUT it is ’02:00:00’??????? Hopes is more clear now. Steffen Mangold _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users