本文介绍了SQL Server找到2等级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的餐桌学生如何找到这张桌子的2个等级
您是否可以为该表编写查询而无需总计如何查找等级
Hi , this my table student how to find 2 rank of this table
can you write query for this table without total how to find rank
studId studName mark1 mark2 mark3
S001 Raja 60 70 40
S002 Siva 40 79 77
S003 Kumar 80 30 90
S004 Mani 60 70 40
-------------------------------------
推荐答案
select * from exam where (mark1+mark2+mark3) = select max(mark1+mark2+mark3) test From eaxm where (mark1+mark2+mark3) not in (select max(mark1+mark2+mark3) test From exam)
with cte_ex as
(select distinct studId,studName,(mark1+mark2+mark3) as sumt,ROW_NUMBER() over (order by (select 1 ))as rowno from tmpstd)
select A.studId,A.studName,A.sumt from cte_ex A
join cte_ex B on A.rowno=B.rowno
where A.rowno=2
这篇关于SQL Server找到2等级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!