如果出现“要是后面的40条记录某一条在本周得分超过前面的20条记录的某一条记录的得分
将会取代该记录”总记录不是没有60条了吗,是不是记录一定要60条?用临时表吧,很方便的!把20条得分最多的记录排序插入#temp,然后,再把本周排序的不在#temp表中的前40条记录插入#temp后,select * from #temp就行了。
将会取代该记录”总记录不是没有60条了吗,是不是记录一定要60条?用临时表吧,很方便的!把20条得分最多的记录排序插入#temp,然后,再把本周排序的不在#temp表中的前40条记录插入#temp后,select * from #temp就行了。
解决方案 »
- 如何求得未出现问题的某型号次数
- 怎么把服务器上的数据库搞到本地
- 请教Sybase和Orcale数据库的客户端配置软件名称
- 十分郁闷的问题!!差点把电脑砸掉
- 书上的一个例子,求助
- 用Lumingent 4.1 Log Explorer 查看SQLServer2005数据库备份,没有数据 No Data fount,q请教如何备份
- 一个字段的问题
- 我在“控制中心”中通过双击tableList看到的是AlterTable的脚本,有什么办法可以看到CreatTable的脚本!
- 从EXCEL向数据库中导入数据遇到问题拉,请各位帮忙啊
- 启动 SQLServer 的 SQL Mail 服务
- 关于数据备份问题
- 请大家帮我找一下为什么错了,有关存储过程的.
union all
select top 40 * from 表 where 上传时间='本周上传的作品' order by 上传时间
union all
select * from (select top 40 * from 表 where 上传时间='本周上传的作品' order by 上传时间) tem2
union all
select * from (select top 40 * from 表 where 上传时间='本周上传的作品' order by 上传时间) tem2
where datepart(wk, getdate()) <> datepart(wk, 上传时间) order by 上周得分 desc
union all
select top 40 * from 表
where datepart(wk, getdate()) <> datepart(wk, 上传时间) order by 上传时间
union all (select id ,本周得分 as [得分] from yourtable )) a
group by a.id order by 得分 desc) b on a.id=b.id
order by case when a.id is null then 0 else 1 end desc,case when a.id is null then 0 else b.得分 end desc,a.上传时间