3 messages in com.googlegroups.sqlalchemy[sqlalchemy] Re: Counts that depend o...
FromSent OnAttachments
Justin Tulloss23 May 2008 14:33 
Justin Tulloss23 May 2008 14:38 
Michael Bayer23 May 2008 16:57 
Subject:[sqlalchemy] Re: Counts that depend on joins
From:Michael Bayer (mike@zzzcomputing.com)
Date:05/23/2008 04:57:56 PM
List:com.googlegroups.sqlalchemy

On May 23, 2008, at 5:33 PM, Justin Tulloss wrote:

Hello,

I am doing a A->B join before I do any filtering on a query object constructed from A. I then to filtering based on C. I have a column_property mapped to A that gives me the total number of B. This is executed as a subquery, which means it gives me the total number of B in the database, not the total number of B after being filtered by C. How do I get the count of B having applied the filter on C?

if "B" is a column_property then it's defined as having a fixed value relative to the "A" which its attached to, just like any other "column" attached to A. If you want the results of a different subquery, youd have to add it to the query using "add_column()", or alternatively linking the Query to a totally custom statement using from_statement().