On Fri Dec 23, 2016 at 02:25:29PM +0100, Clemens Ladisch wrote:
> Lukasz.Stela wrote:
> >The following query returns an error  "1st ORDER BY term does not match
> >any column in the result set".
> 
> This restriction comes from the SQL standard.
> 
> >When I replace the UPPER (Name) by Name - everything works correctly.
> 
> In theory, it would be possible to sort by something that can be derived
> from some column in the result set. But that is not implemented
> in SQLite.

It seems the restriction in SQLite only applies in certain
circumstances (when it is sorting a UNION?):

    sqlite> with a as
        (select 'A' as name union select 'a' as name)
         select a.name from a order by upper(a.name) asc;
    name      
    ----------
    A         
    a         

    sqlite> with a as
         (select 'A' as name union select 'a' as name)
        select a.name from a
        union
         select a.name from a order by upper(a.name) asc;
    Error: 1st ORDER BY term does not match any column in the result set


-- 
Mark Lawrence
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to