>I wonder if I'd be allowed to add an ORDER BY in the subquery and if
>that would make any difference -- I remember reading ORDER BY is only
>allowed in the outer query (which makes perfect sense).

Yes, you can use an order by in a subquery (either a correlated subquery or a 
table generating subquery).  And you can use one in the outer query which will 
be used to order the results.  Whether the order-by clause in a non-correlated 
subquery has any meaning depends on how the query planner decides to perform 
the query.  The order-by in a table generating subquery (that is not 
correlated) may be "pushed" to the outer query just as a where clause in the 
subquery may also get pushed to the outer query as well if the query is 
flattened or if doing so results in a more optimum plan, or so I have observed 
...

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.



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

Reply via email to