在mysql中進行統計排序 跳躍排序和連續排序

2022-05-10 14:42:09 字數 1083 閱讀 7080

-- 在mysql中進行統計排序(跳躍排序和連續排序)

create table `tb_score` (

`id` int(11) not null auto_increment,

`score` int(11) default null,

primary key (`id`),

unique key `id_unique` (`id`)

) select * from tb_score;

delete from tb_score where id > 0;

commit;

insert into tb_score (score) values(43),(22),(22),(18);

commit;

-- 跳躍排序,有並列名次的情況下,整個排序序號不連續

-- 將原表新增一列自增序號的列,然後按照數字進行分組,取得最小的自增序號,在最外層按照各自的最小序號排序

select z.*, x.min_cnt from tb_score z,

(select score, min(cnt) min_cnt from (

(select id, score, (@i:=@i+1) cnt from tb_score, (select @i:=0) as i order by score ) ) a

group by score ) x

where z.score = x.score

order by x.min_cnt;

-- 連續排序,有並列名次的情況下,整個排序序號是連續

-- 將原表對數字進行分組並排序,然後將其做為乙個子表,在上面新增乙個自增的序號

select * from tb_score t , (

select tmp.score, (@i:=@i+1) rank from (

select score from tb_score

group by score order by score asc ) tmp,(select @i:=0) as i ) b

where t.score = b.score

order by b.rank;

在oracle中進行統計排序 跳躍排序和連續排序

在oracle中進行統計排序 跳躍排序和連續排序 create table tb score id number 11 not null primary key,score number 11 default null select from tb score insert into tb scor...

在VBA中進行除錯

只要從您的專案中觸發 vba就會執行。從簡單的開啟表單到單擊命令按鈕,各種各樣的物件事件都可能引起這種情況。當某些事情無法按預期工作時,您如何才能準確確定出什麼問題以及在 好吧,這就是本文可以為您提供的幫助。對於每個office應用程式,當然包括access,都有乙個整合的偵錯程式。要開啟偵錯程式視...

在Release版本中進行除錯

在release版本中進行除錯 許多開發人員在利用visual c 6.0開發程式時,經常會遇到程式在debug版本中能夠正常執行,但是在release版本中就會出現問題的情況。為了在release版本中發現和解決問題,需要在release版本中除錯程式,可是release版本卻不支援除錯,這該怎麼...