赞
踩
取100-150条数据的方法
1. 最佳选择:利用分析函数
row_number() over ( partition by col1 order by col2 )
比如想取出100-150条记录,按照tname排序
select tname,tabtype from (
select tname,tabtype,row_number() over ( order by tname ) rn from tab
) where rn between 100 and 150; 从第100条(包含第100条)到第150条数据,总共51条数据
2. 使用rownum 虚列
select tname,tabtype from (
select tname,tabtype,rownum rn from tab where rownum <= 150
) where rn >= 100;
查询100万到200万之间的数据:
- select ID,
- CASEID,
- PERSONID,
- NAME,
- TYPE,
- STATE,
- ADDRESS,
- PHONENO,
- CONTACT,
- DRIVERLICENSEDOCID,
- DRIVERLICENSEISSUEOFFICE,
- SEX,
- AGE,
- WOUNDINFOID,
- DRIVINGAGE,
- DRIVERLICENSETYPEID,
- CONVEYANCEMEANSID,
- OUTINGPURPOSE,
- ISDRIVER,
- ISWEARINGSEATBELT,
- UPDATETIME,
- UPDATEACCOUNTID,
- PARTYUNIT,
- PERSONAREACODE,
- INJUREDPARTID,
- PERSONALTYPEID,
- ACCIDENTREASONID,
- BUSSINESSCERTIFICATION,
- CORPORATION,
- ESCAPETIME,
- BIRTHDAY,
- CORPERATIONSEX,
- CORPERATIONAGE,
- CORPERATIONADDRESS,
- CORPERATIONCONTACT,
- CORPERATIONIDNUMBER,
- LICENCE,
- MEMO,
- BCISSUER
- from (select ID,
- CASEID,
- PERSONID,
- NAME,
- TYPE,
- STATE,
- ADDRESS,
- PHONENO,
- CONTACT,
- DRIVERLICENSEDOCID,
- DRIVERLICENSEISSUEOFFICE,
- SEX,
- AGE,
- WOUNDINFOID,
- DRIVINGAGE,
- DRIVERLICENSETYPEID,
- CONVEYANCEMEANSID,
- OUTINGPURPOSE,
- ISDRIVER,
- ISWEARINGSEATBELT,
- UPDATETIME,
- UPDATEACCOUNTID,
- PARTYUNIT,
- PERSONAREACODE,
- INJUREDPARTID,
- PERSONALTYPEID,
- ACCIDENTREASONID,
- BUSSINESSCERTIFICATION,
- CORPORATION,
- ESCAPETIME,
- BIRTHDAY,
- CORPERATIONSEX,
- CORPERATIONAGE,
- CORPERATIONADDRESS,
- CORPERATIONCONTACT,
- CORPERATIONIDNUMBER,
- LICENCE,
- MEMO,
- BCISSUER,
- row_number() over(order by id) rn
- from TC_PARTY
- order by id)
- where rn between 1000001 and 2000000
从1000001到2000000,总共100万条数据
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。