> Richard, Before you "fix" it, I'm not convinced it is broken. > > >From MS SQL server > > create table _names (N varchar(5)); > insert into _names values('a'); > insert into _names values('b'); > insert into _names values('c'); > insert into _names values('d'); > insert into _names values('e'); > > select N, RAND() as RNDValue from _names > a 0.301745013642105 > b 0.301745013642105 > c 0.301745013642105 > d 0.301745013642105 > e 0.301745013642105 > > > select N, RAND() as RNDValue from _names where RAND() >=.5; > a 0.0427909435260437 > b 0.0427909435260437 > c 0.0427909435260437 > d 0.0427909435260437 > e 0.0427909435260437
MSSQL isn't the only database that behaves that way (it thinks it can optimize the call if arguments are the same), but it makes difficult to do some tasks (for example ORDER BY random() LIMIT will work fine in sqlite but it will return the same value many times in some other databases). I agree that it may be a matter of documenting the bahaviour (however I like that sqlite evaluating functions in every row) but evaluating functions twice causes problems hard to document: sqlite> select distinct(random() / 5000000000000000000) from (select 1 union select 2); 0 0 --------------------------------------------------------------- Nasilaja sie kradzieze. Mieszkancy osiedli zaniepokojeni. Prosimy o pomoc w tej sprawie >>> http://link.interia.pl/f1eef _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users