MySQL数据库下统计记录数小于指定数值的数据
时间:2021-07-01 10:21:17
帮助过:34人阅读
=
pr.projectMdid
LEFT JOIN Organization city ON city.mdid =
pr.bizOrgMdid
LEFT JOIN Organization org ON org.mdid =
city.parentMdid
LEFT JOIN ( SELECT w.stageMdid stageMdid, count( * ) wcount FROM worker w WHERE w.deleteflag =
0 GROUP BY w.stageMdid ) ws ON st.stageMdid =
ws.stageMdid
WHERE
st.stageMdid IN ( SELECT w.stageMdid FROM worker w WHERE w.deleteflag =
0 GROUP BY w.stageMdid HAVING COUNT( * ) <
30 )
ORDER BY
org.NAME,
city.NAME,
pr.projectName
查出的数据:
当然了,SQL有可以优化的地方,因为只是线下查询一下,对效率没有要求,楼主就这么按照思路写的流水账。
MySQL数据库下统计记录数小于指定数值的数据
标签:col 指定 l数据库 导入 外连接 having ges 了解 mdi