How to execute SELECT DISTINCT ON query using SQLAlchemy
Your SqlAlchemy version might be the culprit.
Sqlalchemy with postgres. Try to get 'DISTINCT ON' instead of 'DISTINCT'
Links to this bug report:https://bitbucket.org/zzzeek/sqlalchemy/issues/2142
A fix wasn't backported to 0.6, looks like it was fixed in 0.7.
Stupid question: have you tried distinct on SpendEstimation.date
instead of 'date'
?
EDIT: It just struck me that you're trying to use the named column from the SELECT
. SQLAlchemy is not that smart. Try passing in the func
expression into the distinct()
call.