select * from @a a where not exists(select 1 from @a where sclass=a.sclass and sscore>a.sscore and sname='jake') and sname='jack'
解决方案 »
- [求教:一次性更新50W条数据]
- 查找当月数据的问题?
- 如何将sql无日志文件的数据恢复
- ---求SQL语句---
- 如何得到系统中的表的字段、字段类型、长度、是否为空、是否主键、缺省值等信息?
- 在mssql中我想监视一个数据库的所有操作,用存储过程能实现吗?来着有分
- 请问大力,愉快的登山者等,这个问题!
- 在win2000 server 中装sql7.0 注册表已没有SQL的信息,最后配置服务器时报错:SQL7.0安裝過程中出現的一個問題:Setup failed to configure
- 关于sql server中的替换问题
- 怎样编写触发器!一个很简单的触发器
- sql server中bcp命令参数如何传递
- 一个有关数据更新触发的问题
select *
from chunting.dbo.student_score a
where not exists(select 1
from chunting.dbo.student_score
where sclass=a.sclass
and sscore>a.sscore
and sname='jack') and sname='jack'
select e.sid,e.sname,max(e.sscore) over (partition by sclass) sscore
from (
select sid,sname,sclass,sscore,
rank() over(partition by sclass order by sscore desc) as rn
from chunting.dbo.student_score
where sname='zhang san'
) e
where e.rn=1
from (
select sid,sname,sclass,sscore,
rank() over(partition by sclass order by sscore desc) as rn
from chunting.dbo.student_score
where sname='zhang san'
) e
where e.rn=1