Am 06.06.2013, 18:56 Uhr, schrieb Ladislav Lenart <lenart...@volny.cz>:

Hello.
I have already solved the issue by using subquery:
SELECT
    t.id AS t_id,
    t.rownum AS t_rownum
FROM (
    SELECT
    FROM
        foo.id AS id,
        row_number() OVER (ORDER BY foo.id) AS rownum
) AS t
WHERE rownum % 50 = 1

I have just tried your suggestion about using HAVING instead of WHERE, but that fails with the same error. Thus a label cannot be used inside a query.

Yeah, sorry. As it says in the docs:

"""
If the query contains any window functions (see Section 3.5, Section 9.21 and Section 4.2.8), these functions are evaluated after any grouping, aggregation, and HAVING filtering is performed
"""

So, it would be possible with standard aggregate functions, well something like it is, but not with anything like row_number() which must use a window. Compared with Python seems a weird way of striding through the results but maybe that's just SQL.

Charlie
--
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Kronenstr. 27a
Düsseldorf
D- 40217
Tel: +49-211-600-3657
Mobile: +49-178-782-6226

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


Reply via email to