count:

from sqlalchemy import func

# count User records, without
# using a subquery.
session.query(func.count(User.id))

# return count of user "id" grouped
# by "name"
session.query(func.count(User.id)).\
        group_by(User.name)

from sqlalchemy import distinct

# count distinct "name" values
session.query(func.count(distinct(User.name)))

下面展示一个综合的:

self.orm.session.query(NiuceModel.level,func.count(BugDetail.id).label('count')).filter(and_(BugDetail.app_id == app_id,NiuceModel.id == BugDetail.bug_name)).group_by(NiuceModel.level).all()

 

 

..

相关文章:

  • 2022-01-03
  • 2021-11-09
猜你喜欢
  • 2021-11-05
  • 2022-01-26
  • 2022-12-23
  • 2022-12-23
  • 2022-01-16
  • 2021-10-09
  • 2021-06-05
相关资源
相似解决方案