给mysql查询添加序号列
时间:2021-07-01 10:21:17
帮助过:34人阅读
*,(@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 ,上面是多个表的例子
但个表的例子如下:
给mysql查询添加序号列
标签:查询 info hresult 例子 sel ges har nan charge