Group by hour in SQLAlchemy?

后端 未结 5 726
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-15 10:43

How do I group query results by the hour part of a datetime column in SQLAlchemy?

5条回答
  •  时光说笑
    2020-12-15 11:24

    If I remember correctly you must first extract the hour from your timestamp and then you can group by that.

    query(extract('hour', timeStamp).label('h')).group_by('h')
    

提交回复
热议问题