比如你的TOP限制是10
創(chuàng)新互聯(lián)堅(jiān)信:善待客戶,將會(huì)成為終身客戶。我們能堅(jiān)持多年,是因?yàn)槲覀円恢笨芍档眯刨?。我們從不忽悠初訪客戶,我們用心做好本職工作,不忘初心,方得始終。十余年網(wǎng)站建設(shè)經(jīng)驗(yàn)創(chuàng)新互聯(lián)是成都老牌網(wǎng)站營(yíng)銷服務(wù)商,為您提供成都做網(wǎng)站、網(wǎng)站設(shè)計(jì)、網(wǎng)站設(shè)計(jì)、H5場(chǎng)景定制、網(wǎng)站制作、品牌網(wǎng)站設(shè)計(jì)、微信小程序定制開發(fā)服務(wù),給眾多知名企業(yè)提供過好品質(zhì)的建站服務(wù)。
在ORACLE中就是where
后面添加rownum10這個(gè)條件
可以這么寫:
"select
*
from
cs_service
where
rownum"
+pageSize
+"and
supplierId
not
in
(select
supplierID
from
cs_service
where
rownum"
+number
+"order
by
servicetype
desc)
"
+"order
by
servicetype
desc"
Oracle9i之前,中文是按照二進(jìn)制編碼進(jìn)行排序的。在oracle9i中新增了按照拼音、部首、筆畫排序功能。
1、設(shè)置NLS_SORT參數(shù)值
SCHINESE_RADICAL_M 按照部首(第一順序)、筆劃(第二順序)排序 SCHINESE_STROKE_M 按照筆劃(第一順序)、部首(第二順序)排序 SCHINESE_PINYIN_M 按照拼音排序
2、Session級(jí)別的設(shè)置,修改ORACLE字段的默認(rèn)排序方式:
按拼音:alter session set nls_sort = SCHINESE_PINYIN_M;
按筆畫:alter session set nls_sort = SCHINESE_STROKE_M;
按偏旁:alter session set nls_sort = NLS_SORT=SCHINESE_RADICAL_M;
3、語(yǔ)句級(jí)別設(shè)置排序方式:
按照筆劃排序 select * from dept order by nlssort(name,'NLS_SORT=SCHINESE_STROKE_M');
按照部首排序 select * from dept order by nlssort(name,'NLS_SORT=SCHINESE_RADICAL_M');
按照拼音排序 此為系統(tǒng)的默認(rèn)排序方式
select * from dept order by nlssort(name,'NLS_SORT=SCHINESE_PINYIN_M');
4、修改系統(tǒng)參數(shù)(數(shù)據(jù)庫(kù)所在操作系統(tǒng)):
set NLS_SORT=SCHINESE_RADICAL_M export NLS_SORT (sh) setenv NLS_SORT SCHINESE_RADICAL_M (csh) HKLC\SOFTWARE\ORACLE\home0\NLS_SORT (win注冊(cè)表)
sqlserver或者oracle如下:
創(chuàng)建表,數(shù)據(jù):
create?table?t(id?int,star?int)?insert?into?t?values?(1,1)insert?into?t?values?(2,3)insert?into?t?values?(3,5)insert?into?t?values?(4,2)insert?into?t?values?(5,2)insert?into?t?values?(6,1)insert?into?t?values?(7,5)insert?into?t?values?(8,4)insert?into?t?values?(9,2)insert?into?t?values?(10,2)insert?into?t?values?(11,3)insert?into?t?values?(12,3)insert?into?t?values?(13,4)
執(zhí)行:
select?id,star?from(select?t.*,row_number()?over?(partition?by?star?order?by?id)?rn?from?t)?tmporder?by?rn,star
結(jié)果大概這個(gè)樣子:
其他數(shù)據(jù)庫(kù)另說,就沒這么簡(jiǎn)單了。