Hi all, I've searched through the documentation and google on this and haven't been able to find an answer. I have the following class:
class Price(Base): __tablename__ = "prices" id = Column(Integer, primary_key = True) company_id = Column(Integer, ForeignKey('companies.id')) date = Column(DateTime, nullable=False) close = Column(Float) I'm trying to query Price for the minimum price during a certain period of time. The query for that is: session.query(func.min(Price.close)).join(Company).filter(and_(Company.ticker=="AAPL", Price.date>=<datetime object>)).one() But, how does one query the Price.date that corresponds to func.min(Price.close)? I had thought I could do session.query(Price.date, func.min(Price.close)... but that instead returned the first date in the column alongside the min price. I also thought that I could do: session.query(Price.date).join(Company).filter(Company.ticker=="AAPL").having(func.min(Price.adj_close)==low[0]).all() But that returns the empty set for some reason. (Just as well--there has to be an easier way to do this.) Chris -- 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/groups/opt_out.