数据表字段怎么求和?
数据表 qb_shop_content 里有N篇文章,fid=1 - N; 篇 里的jinbi字段的和,select怎么写?
如 fid=1 uid=1 jinbi=5
fid=2 uid=1 jinbi=10
fid=3 uid=1 jinbi=3
fid=N uid=1 jinbi=N
jinbi=(fid=1的金币数)+(fid=2的金币数)+(fid=3的金币数)+(fid=N的金币数)
------解决方案--------------------SELECT sum(jinbi),uid AS fennum FROM qb_shop_content
group by uid
------解决方案--------------------SQL code
select uid,sum(jinbi)
from qb_shop_content
group by uid
------解决方案--------------------
select sum(jinbi) from qb_shop_content
------解决方案--------------------
SQL code
select sum(jinbi) as jinbi from qb_shop_content
where uid=1