SQL Server 2008的更新语句 现有数据如上。要使所有以ID为个体的tot_cred的值为对应的所有credits的总和,怎么办?例如:00128,tot_cred=7 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 update aset credits=b.creditsfrom tb a, (select tot_cred,sum(credits) as credits group by tot_cred)bwhere a.tot_cred=b.tot_cred update TBset TB.credits = T.creditsfrom TBinner join (select ID,sum(credits)as credits from TB)T on T.id = TB.id group by ID 忘记加了。Godupdate TBset TB.credits = T.creditsfrom TBinner join (select ID,sum(credits)as credits from TB group by ID)T on T.id = TB.id update aset credits=b.creditsfrom tb a,(select tot_cred,sum(credits) as 'credits' from a group by tot_cred)bwhere a.tot_cred=b.tot_cred update aset credits=(select sum(credits) as credits WHERE tot_cred=a.tot_cred AND ID=a.ID)from tb a update aset credits=b.creditsfrom tb a,(select tot_cred,sum(credits) as [credits] from a group by tot_cred)bwhere a.tot_cred=b.tot_cred sql语句可以这样加密的吗? 关于实现"未阅"功能相关数据库的设计 不重复数据 请帮忙优化一条sql语句!谢谢! 大家来帮忙看看这个这么搞定? 一个关于游标更新表的问题 select DateValue(RegTime) from xxx...??? 求教在WINDOW XP个人版上,装sql2000个人版数据库,为什么会出这样的问题?在线等待 不能在firehose方式下启动事务是什么意思? 关于SQL Server的查询日志问题。 SQL语句求解 SQL2008压缩日志文件
a
set
credits=b.credits
from
tb a,
(select tot_cred,sum(credits) as credits group by tot_cred)b
where
a.tot_cred=b.tot_cred
set TB.credits = T.credits
from TB
inner join (select ID,sum(credits)as credits from TB)T on T.id = TB.id
set TB.credits = T.credits
from TB
inner join (select ID,sum(credits)as credits from TB group by ID)T on T.id = TB.id
set credits=b.credits
from tb a,
(select tot_cred,sum(credits) as 'credits' from a group by tot_cred)b
where a.tot_cred=b.tot_cred
update a
set credits=(select sum(credits) as credits WHERE tot_cred=a.tot_cred AND ID=a.ID)
from tb a
set credits=b.credits
from tb a,
(select tot_cred,sum(credits) as [credits] from a group by tot_cred)b
where a.tot_cred=b.tot_cred