排名以及進步情況寫法!

2021-04-12 17:04:23 字數 1675 閱讀 7449

here

學生總分

名次進步指數 

王五98

1---

李四652-1

張三563+1

:實現結果圖

--定義表結構

declare @rrt_exam_class table(rrt_examid int ,rrt_classid int )

insert into @rrt_exam_class             --班級測試情況表

select 1,1 union select 2,1

declare @rrt_exam_mark table(rrt_examid int ,rrt_stid int,rrt_mark int )

insert into @rrt_exam_mark               --測試成績表

select 1,3,99 union select 2,3,98

union select 1,1,98 union select 1,2,52

union select 2,1,56 union select 2,2,65

declare @rrt_class table(rrt_classid int ,rrt_classname varchar(20) )

insert into @rrt_class select  1,'初一(1)班'    --班級表

declare @rrt_student table(rrt_stid int ,rrt_stname varchar(20) ) --學生表

insert into @rrt_student

select 1,'張三' union select 2,'李四' union select 3,'王五' 

--實現

select 學生,總分,名次,進步指數=(case when 進步指數》0 then '+'+ltrim(進步指數)

when 進步指數<0 then ltrim(進步指數) else '--' end)

from (

select 學生,總分,名次,進步指數=名次-isnull(上次名次,名次)

from ( select  b.rrt_examid,學生=a.rrt_stname,總分=b.rrt_mark,

名次=(select count(*) from @rrt_exam_mark

where rrt_examid=b.rrt_examid and rrt_mark>=b.rrt_mark),

上次名次=(select count(*) from @rrt_exam_mark as r

where rrt_examid=b.rrt_examid-1 and (

select rrt_mark from @rrt_exam_mark 

where rrt_examid=b.rrt_examid-1 and rrt_stid=b.rrt_stid)<=r.rrt_mark )

from @rrt_student as a inner join @rrt_exam_mark as b 

on a.rrt_stid=b.rrt_stid ) as t

where not exists(select * from @rrt_exam_class

where rrt_examid>t.rrt_examid) ) as tb order by 名次

國內CDN的排名情況

cdn的指標通常由以下幾項組成,分別是 丟包率 指使用者在網路傳輸中所丟失資料報數量佔所傳送資料組的比率。回源率 回源率分為回源請求數比例及回源流量比例兩種。快取命中率 指終端使用者訪問加速節點時,該節點已快取了要被訪問的資料的次數佔全部訪問次數的比例。快取命中率越高,效能越好。阿里雲 先進的分布式...

對資料進行比較分出排名,排名會有相同的情況。

1.首先假造一點資料 建立乙個person類 getset構造方法自己補充 public class person2.接下來new出幾個物件來加進集合中 arraylistpersonlist new arraylist person person new person 張三 5 建立了只有名字和接...

WPF 各種繫結寫法以及用法

一 elementname grid0 查詢到名為 grid0的控制項。path height 獲取 名為grid0的控制項的 height屬性值。即 將lb1的屬性值設定為 grid0控制項的 height屬性設定值。grid name grid0 grid stackpanel backgrou...