zone_assign_infos = ZoneConfigInfo.query.outerjoin(
GameConfigMap,
ZoneConfigInfo.id == GameConfigMap.config_file_id
).with_entities(
ZoneConfigInfo.id,
ZoneConfigInfo.file_type,
db.func.count(GameConfigMap.id).label('num')
).group_by(ZoneConfigInfo.id).order_by(desc('num'))
ret = [{'id': i[0], 'name': i[1], 'num': i[2]} for i in zone_assign_infos]
return {'data': ret}
SELECT
qy_zone_config_file_info.id AS qy_zone_config_file_info_id,
qy_zone_config_file_info.file_type AS qy_zone_config_file_info_file_type,
count( qy_game_config_map.id ) AS num
FROM
qy_zone_config_file_info
LEFT OUTER JOIN qy_game_config_map ON qy_zone_config_file_info.id = qy_game_config_map.config_file_id
GROUP BY
qy_zone_config_file_info.id
ORDER BY
num DESC
网友评论