Let's say I have a an `Event`, `Facility`, `Producer`.
How do I calculate aggregation result of a single field with different 
filters ?
Here is an example:
`class Facility:
   name = ...
   events = relashionship(...

class Event:
   facility_id = ...
   producer = ....
   start_date = ...`

The query:
`session.query(
    Faciltity.name,
    func.count(Facility.events).filter(Event.producer == 
some_event_producer_id),
    func.count(Facility.events)
        .filter(Event.producer == some_event_producer_id)
        .filter(Event.start_date < some_beginning_date)).all()`

Can it be done like this ?
I was able to implement the query only when one aggregation is needed using 
`join` and `group_by`. However, I'm confused what do you when I have two 
aggregate functions for the same field.

Muchos gracias!

Andrey

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to