我正在尝试按月对一些事件进行分类。
date_list = func.generate_series(start, end, '1 month')
db.session.query(func.count(Event.id)).join(date_list, true()).outerjoin(Event, Event.time==func.date(date_list)).all()
Run Code Online (Sandbox Code Playgroud)
但我收到一个错误:
NotSupportedError: (psycopg2.errors.FeatureNotSupported) 在 JOIN 条件中不允许使用集合返回函数
在 SQLAlchemy 连接的左侧使用一系列,然后使用类似计数的聚合的简单示例是什么?