whats the SQL you're looking for ?    work it out from a SQL perspective first 
- get an exact SELECT, then run it straight on that database, to work out what 
should be done here.  Window functions + DISTINCT + LIMIT/OFFSET sounds like 
it's really getting out there, and I'm not even sure what various DB's would be 
doing in response to that.


On May 16, 2012, at 10:05 AM, Eduardo wrote:

> To put it more clear why:
> rows = session.query(*[func.count().over().label("count")]+map(lambda column: 
> MyClass.__dict__[columns],columns)).filter(...).limit(n).offset(m).all()
> works and
> rows = session.query(*[func.count().
> over().label("count")]+map(lambda column: 
> MyClass.__dict__[columns],columns)).filter(...).distinct().limit(n).offset(m).all()
> does not?
> Thanks
> 
> 
> 
> 
> 
> Am Mittwoch, 16. Mai 2012 12:07:26 UTC+2 schrieb Eduardo:
> Hello,
> I have got a query of the following type:
> 
> rows = session.query(*[func.count().over().label("count")]+map(lambda column: 
> MyClass.__dict__[columns],columns)).filter(...).limit(n).offset(m).all()
> 
> it returns the number of results together with values of selected columns. 
> The problem is when I try to apply the distinct query I see that 
> func.count().over().label("count") does not return correct results, that is, 
> it returns the number of results for the query by which the distinct function 
> is omitted.
> Is there any workaround for this problem?
> The query contains no joins.
> Thank you
> ED
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/sqlalchemy/-/W80zRGtGptAJ.
> 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.

-- 
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