求助:两表的交叉查询求均价,急,在线等. 我要的最后三次的加权平均值,不是全部的.所以这一行的3 电风扇 71.00 68.58就不对了. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可否改为:select a.* ,newprice = isnull( (select top 3 cast(sum(total)/sum(account)as decimal(10,2)) from @t1 where a.id = productid order by pid desc) ,price)from @t a 请问这个怎么写,谢谢! 求一動態SQL語句? sql server 2005如果有许多并发,执行procedure时会慢很多,这个procedure只是一个报表 identity的问题 高手求救,如何将SQL数据库中的..sstttt12358..[ss]换成[ff],求sql语句 简单问题 sql语句错误,请指教 select的模糊查询 急急!!!! 在线等待....数据库中的id问题... 在包含有unique identifier的字段数据库中,怎么插入数据啊? 怎么修改主键 求一精简SQL语句
select a.*
,newprice = isnull(
(select top 3 cast(sum(total)/sum(account)as decimal(10,2)) from @t1 where a.id = productid order by pid desc)
,price)
from @t a