Ok, thank you.

I know about

> SELECT a, b FROM x ORDER BY c

I just don't know how to write it because I (think I) need to define the literal
column as one of the CTE columns. I have to increment it in each iteration. I
will play with it for a while and see where it will lead me to.

Thank you again for your time,

Ladislav Lenart


On 17.9.2012 16:05, Michael Bayer wrote:
> 
> On Sep 17, 2012, at 9:23 AM, Ladislav Lenart wrote:
> 
>>
>> Hm, I see. My train of thought: This particular query returns the path from a
>> selected node to the root. Each iteration adds one row to the result set (one
>> new parent). I thought that UNION ALL keeps the order intact and thus no
>> order_by clause is needed. I guess I was wrong.
> 
> nothing except ORDER BY orders rows in SQL.  All the rest is an artifact of 
> how the query executes.
> 
>>
>> I can add a depth/iteration column (via literal_column) and order_by it. 
>> However
>> I still want the results to be a list of Node instances (i.e. without the 
>> added
>> depth column). How can I write such a query?
> 
> you can order_by() any expression, and that expression does not need to be in 
> the columns clause.   That is:
> 
> SELECT a, b FROM x ORDER BY c
> 
> 
> is just as valid as
> 
> SELECT a, b, c FROM x ORDER BY c

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to