❶ sql語句 撈出各班級總分第二的人
--按班級分組 最大的總分 去掉最大的分數 就是第二名
select x.* from A x,
(select classId,max(Math+English+Yuwen) as SecondScore from A
where Id not in --先去掉總分第一名的id
(select A.ID from A,
(select ClassId,max(Math+English+Yuwen) as TotalScore from A
group by ClassId) t
where a.Math+a.English+a.Yuwen=t.TotalScore and A.ClassId=t.ClassId)
group by classId) temp
where x.Math+x.English+x.Yuwen=temp.SecondScore
and x.ClassId=temp.ClassId
❷ 有表名Student,有欄位Id為學號,和FeiShu為成績,請以SQL語句,找出成績排名第二的學
看是什麼資料庫,以sql server為例
select id from student where feishu in ( select top 2 feishu from student order by feishu desc )
and feishu <> ( select max(feishu) from student ) ;
估計可以吧~
就是查詢最高分數的前兩名 和 去除最高分 , 獲得第二名的id ;
❸ sql語言,有一個成績單表,已知學生姓名,如何查詢名次
1、創建測試表,
create table test_score(name varchar2(20), score number);
❹ SQL 查找第二高的
select top 2 * from [學生表] where id not in (select top 1 * from [學生表] order by [成績] ) order by [成績]
查出前2名,不在第一名的裡面就是第二名了啊,1樓的是錯的,哪有order by 在where條件前面的啊!
❺ sql 如何查找出每個月成績進步最快的同學是誰
假設學生成績表為xscj,裡面有若干個欄位,其中包括具體成績得分欄位df,那麼,查詢所有成績第二高學生的SQL語句如下: select * from xscj where df in ( select max(df) from xscj where df not in ( select max(df) from xscj)) 該語句嵌套基層,最內層的語句查詢最高分,第二層的語句查詢除了最高分以外後剩下的最高分(即第二高分),最外層即是查詢第二高分有哪些人(可能存在多人的情況)。
❻ sql 查找成績排名第二的同學
你這信息不足以讓我了解如何給你答案,很明顯,如果第一名有並列、第二名也有並列的情況,以上各位用top的答案都是錯的。
因此,建議你將表結構給出來,我好幫你分析問題。
或者你試試看這樣:
select * from tbl_score where score =
(
select distinct top 1 score from tbl_score where score not in(
select distinct top 1 score from tbl_score order by score desc
) order by score desc
)
我在我自己的臨時表測試過,應該這樣就可以滿足的了查詢成績第二的情況,包括並列第二的所有人。
不知道樓主是否想要的就是這樣?
❼ sql查詢最大的見多了,查詢第二的呢
使用max求出每個學生的最好成績,語句如下:
select 學號, max(跳遠成績) 最好跳遠成績 from 跳遠成績表 group by 學號;
❽ SQL語句如何查詢成績第二高的學生
用的是什麼資料庫?如果是mysql 的話可以這樣:
-- 找到第二高的分數
select min(score) from (select distinct score from scores order by score desc limit 2) a;
-- 找到記錄
select * from scores where score in (select min(score) from (select distinct score from scores order by score desc limit 2) a);
其中score是分數,scores是數據表。
❾ SQL 語句 找出一個班級里成績在第二十名到第三十名的學生信息出來.
select top 10 * from (
select top 30 * from t1 order by chengji desc
) aa order by aa.chengji
❿ sql 各科的成績排序怎麼排名次
各科成績的表達有兩種:
科目 成績排名 科目成績排名
數學 90 1 數學 90 1
語文 90 1 語文 90 1
政治 85 3 政治 85 2
#這是第一種的顯示
seclet科目,成績,(
selectcount(成績)+1
fromtable_namewhere成績>t.成績)
fromtable_nameast
orderby成績desc
#第二中的顯示類似可以是加distinct或者是不加distinct而用分組groupby一個意思
seclet科目,成績,(
selectcount(distinct成績)
fromtable_namewhere成績>=t.成績)
fromtable_nameast
orderby成績desc