分析函数指定行号(rowno),最后按照行号筛选数据即可;
脚本中使用了Oracle数据库方言(特有函数),执行SQL时需加上方言标记(/*dialect*/),具体查询脚本请参考下文。--查询前5000行
/*dialect*/
select * from (select t.*, row_number() over (order by t.PATIENT_CODE) rowno from (
select distinct cus.FID ID, cus.FNumber PATIENT_CODE, cus.FName_L2 SURE_NAME,
(case crm.FCustSex when 0 then 'M' when 1 then 'F' else '-' end) SEX_TYPE, --性别
to_char(crm.CFBirthday, 'yyyy-MM-dd') BIRTHDAY, --生日
crm.CFDefaultPhone MOBILE_PHONE, crm.FDefaultTel HOME_PHONE, --手机号、备用号
cou.FName_L2 COUNTRY, folk.FName_L2 NATIONALITY, --国家、民族
org.FNumber ORGNO, org.FName_L2 ORGNAME --财务组织编码、名称
from T_BD_Customer cus --客户主数据
inner join T_BD_CSSPGroup grp on cus.FBrowseGroupID = grp.FID --客户分类
inner join T_MS_CustomerCrmInfo crm on cus.FID = crm.FCustomerID --客户CRM信息
inner join T_ORG_Company org on crm.FFICompanyID = org.FID --财务组织
left join T_BD_Country cou on crm.CFCountryID = cou.FID --国家
left join T_BD_HRFolk folk on crm.FNationID = folk.FID --民族
where grp.FNumber in ('001', '002', '003') --限定客户分类
and cus.FUsedStatus = 1 --核准状态
and org.FNumber = '1001' --财务组织编码
) t) where rowno < 5001--查询5001到10000行
/*dialect*/
select * from (select t.*, row_number() over (order by t.PATIENT_CODE) rowno from (
select distinct cus.FID ID, cus.FNumber PATIENT_CODE, cus.FName_L2 SURE_NAME,
(case crm.FCustSex when 0 then 'M' when 1 then 'F' else '-' end) SEX_TYPE, --性别
to_char(crm.CFBirthday, 'yyyy-MM-dd') BIRTHDAY, --生日
crm.CFDefaultPhone MOBILE_PHONE, crm.FDefaultTel HOME_PHONE, --手机号、备用号
cou.FName_L2 COUNTRY, folk.FName_L2 NATIONALITY, --国家、民族
org.FNumber ORGNO, org.FName_L2 ORGNAME --财务组织编码、名称
from T_BD_Customer cus --客户主数据
inner join T_BD_CSSPGroup grp on cus.FBrowseGroupID = grp.FID --客户分类
inner join T_MS_CustomerCrmInfo crm on cus.FID = crm.FCustomerID --客户CRM信息
inner join T_ORG_Company org on crm.FFICompanyID = org.FID --财务组织
left join T_BD_Country cou on crm.CFCountryID = cou.FID --国家
left join T_BD_HRFolk folk on crm.FNationID = folk.FID --民族
where grp.FNumber in ('001', '002', '003') --限定客户分类
and cus.FUsedStatus = 1 --核准状态
and org.FNumber = '1001' --财务组织编码
) t) where rowno between 5001 and 10000
标签:cus,行后,join,6500,查询,--,FID,org,crm
From: https://www.cnblogs.com/ketoli/p/17190938.html