Skip to content

Instantly share code, notes, and snippets.

@youqingkui
Created August 14, 2015 01:43
Show Gist options
  • Save youqingkui/04bad8151e13640ea60c to your computer and use it in GitHub Desktop.
Save youqingkui/04bad8151e13640ea60c to your computer and use it in GitHub Desktop.
MySQL按照记录条数排序
# SELECT * , count(desire_id) AS num
# FROM desire_tran
# GROUP BY desire_id
# ORDER BY num DESC
q = q.filter(DesireInfo.desire_id == DesireTran.desire_id).filter(DesireTran.is_real == 1)\
.group_by(DesireInfo.desire_id).distinct()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment