select *,(@number := @number+1) AS number from (select u.mobile,u.`name`, ROUND((select sum(r.realAmount) from t_recharge r where r.userid=u.id and r.status=‘1‘ ),2)rechargeSum, ROUND((select sum(w.realAmount) from t_withdrawal w where w.userid=u.id and w.status=‘1‘ ),2)withdrawalSum, ROUND(sum(f.ownAmount),2)ownAmountSum, ROUND(sum(f.platformFunds),2)platformFundsSum, ROUND((select sum(fd.amount) from t_fund_detail fd where fd.userid=u.id and fd.type=‘3‘ ),2)feeSum, ROUND(sum(f.result),2) cashResult , u.balance,u2.`name` as froms from t_user u left join t_financing f on f.userid=u.id LEFT JOIN t_user u2 ON u2.id = u.fromId group by u.id ) temp ,(select @number :=0) b
用到的是(@number := @number+1) AS number和(select @number :=0) b ,上面是多个表的例子
但个表的例子如下:
原文地址:https://www.cnblogs.com/-scl/p/8484479.html
时间: 2024-09-28 19:35:05