SQLite Forum

Getting rid of double DATE()
Login
The former.  

Putting the table now in the join and using lastused == today indicates that the descent order needs to be from the now into selectRandom -- the date function is only executed once (it must be materialized).

If you remove now from the join and instead use a scalar constant select then the query flattener will merely substitute the constant computation resulting in the date function being executed twice because there is not longer a join to optimize.