Hi everyone!
I'm trying to concoct a somewhat complicated query via Query API.. The
situation is the following:

- A many-to-one relation between classes C and D
- Class C has an attribute "value"

My objective is to retrieve the ids of a left outer join between D and
C (so, all the Ds and eventually the related Cs) where C.value has the
maximum value, given the same D.

So for example, given a table D made of
[id, otherfield]
(1, "A")
(2, "B")
(3, "C")

and a table C made of
[id, d_id, value]
(1, 1, 0)
(2, 1, 1) <- max value for d_id 1
(3, 2, 3) <- max value for d_id 2
(4, 2, 2)

I'd like my query to return
[d.id, c.id]
(1, 2)
(2, 3)
(3, None)

Is this possible with a single query?
Many thanks for your time!
--~--~---------~--~----~------------~-------~--~----~
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