On Mar 28, 2008, at 11:53 AM, Julien wrote:
> > It doesn't work because more than one row are returned by the subquery > used in the expression ... thats not what "as_scalar()" means (not to be confused with "scalar()"). it just means the select() object will be treated as though it were a column, and will not export its FROM to the from clause of the enclosing select (i.e., its "scalar" within the row). like so: from sqlalchemy import * from sqlalchemy.sql import table, column t = table('t', column('a'), column('b')) s = select([t.c.a]) >>> print select([func.count(s)]) SELECT count((SELECT t.a FROM t)) AS count_1 FROM (SELECT t.a AS a FROM t) >>> print select([func.count(s.as_scalar())]) SELECT count((SELECT t.a FROM t)) AS count_1 --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---