Am 06.06.2013, 16:30 Uhr, schrieb Ladislav Lenart <lenart...@volny.cz>:

The returned query q produces the following SQL:
   SELECT
        foo.id AS foo_id,
        row_number() OVER (ORDER BY foo.id) AS rownum
    FROM foo
    WHERE rownum % 2 = 1
When executed, it generates the following error:
   sqlalchemy.exc.ProgrammingError:
        (ProgrammingError) column "rownum" does not exist

Just a guess but the error is coming from Postgres. You'll need to doublecheck the docs but I don't think "rownum" is available for the WHERE clause because OVER works like the aggregate functions. You can either try wrapping the SELECT in correlated subquery as the example shows or simply use HAVING rownum % 2 = 1 (I think this is best approach but I'm far from an expert). Try the SQL directly in the DB to see which works.

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