2
我有一個查詢產生一個id,後跟一個計數。我只想得到那些計數爲N的行。我嘗試了下面的代碼,但是我得到'錯誤:列'cert_count「不存在'。我想我使用的標籤是錯的?SQLAlchemy:使用標籤進一步過濾查詢
cust_cert_counts = db.session.query(
CustomerCertAssociation.customer_id,
func.count(CustomerCertAssociation.certification_id).label('cert_count')).filter(
CustomerCertAssociation.certification_id.in_(cert_ids)).group_by(
CustomerCertAssociation.customer_id)
cust_cert_counts.filter('cert_count=2').all()