Hi,

I would like to use distinct inside a group_by query, e.g.:

session.query(Product.attribute_x, func.min(Product.price), 
distinct(Product.color)). group_by(Product.attribute_x)

That is, for each value of attribute_x, I want to find the lowest price and 
all of the colors available.

I don't seem to be able to use distinct in this way. Can anyone please 
suggest an efficient method of identifying the distinct colors for each 
value of attribute_x (without creating a new query for each value of 
attribute_x)?

Thank you,
Andrew

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/949655c4-eacb-46fd-ae68-48a7aa1a3446%40googlegroups.com.

Reply via email to