On Tue, Aug 25, 2015 at 7:16 PM, Stephen Chrzanowski
<pontiac76 at gmail.com> wrote:
> Somewhat of a devils advocate here, but I'm not sure one can order based on
> JUST data.  Take the DATE function, for example.  If, by your words, ORDER
> BY should only act on the data, consider this kind of query:
>
> select ItemName,SoldDate from SoldItemDetails order by
> SoldDate<date('now','-1 month') desc,SoldDate asc;
>
> [untested, but here's the theory]
>
> What this theoretical query would do is list all items in the table
> grouping items sold in the past month at the top of the list, then, order
> by the date in ascending order.  Considering DATE isn't part of the data,
> you now have to open up the door to judging what should and shouldn't be
> considered to be evaluated by ORDER BY.
>
but, your order by is the only place that uses the date function... it
would have to be reversed as
elect ItemName,SoldDate, date('now','-1 month') as z from
SoldItemDetails order by
 SoldDate<z desc,SoldDate asc;

which I would think would evalutate to a token 'z' and use that same
value, not retain it as a function.

select random() order by random() should definately reprocess the function...


> On Tue, Aug 25, 2015 at 10:00 PM, James K. Lowden <jklowden at 
> schemamania.org>
> wrote:
>
>>
>> ORDER BY should evaluate the *data* only.  In the case of random(),
>> like any other function it gets invoked once, by SELECT, and produces a
>> value.  That value is the one that ORDER BY should operate on.
>>
>> --jkl
>> _______________________________________________
>> sqlite-users mailing list
>> sqlite-users at mailinglists.sqlite.org
>> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to