$m = D("qipai_logic.roomhisscoredetail"); $where[‘uid‘] = $uid; $productinfo = $m->where($where)->field(‘roomid,uid,name,max(turn) as roomturn‘)->group(‘roomid‘)->buildSql();//子查询 $allturn = M()->table($productinfo.‘ a‘)->field(‘uid,name,sum(roomturn) allturn‘)->select(); //总局数