SELECT c.name_id, c.order_county, IFNULL(d.count,0) AS count FROM ( SELECT a.id, a.name_id, b.order_county FROM (SELECT a.name_id, 1 AS id FROM zty_info AS a GROUP BY a.name_id) AS a LEFT JOIN ( SELECT b.order_county, 1 AS id FROM zty_info AS b GROUP BY b.order_county ) AS b ON a.id=b.id ) AS c LEFT JOIN ( SELECT e.name_id, e.order_county, COUNT(*) AS count FROM zty_info AS e GROUP BY e.name_id,e.order_county ) AS d ON c.name_id=d.name_id AND c.order_county=d.order_county 数据顺序自己最后重新排序就行
2 1

相关推荐

拒绝无效加班的小师弟很中意你:求职意向没有,年龄、课程冗余信息可以删掉,需要提升项目经历。排版需要修改。
点赞 评论 收藏
分享
牛客网
牛客企业服务