SELECT * FROM ( SELECT ROW_NUMBER() OVER (order by T. code)AS TmpRow, T.*, (case
when t.jb = 1 then '国'
when t.jb = 2 then '省'
when t.jb = 3 then '市'
when t.jb = 4 then '县'
when t.jb = 5 then '乡镇'
when t.jb = 6 then '村'
when t.jb = 7 then '村民小组'
else '' end
) jb_show,
substr(t.code, 0, 2) || '0000000000' province_code,
(select name from DIVISIONS where substr(t.code, 0, 2) || '0000000000' =code) province_name,
substr(t.code, 0, 4) || '00000000' city_code,
(select name from DIVISIONS where substr(t.code, 0, 4) || '00000000' =code) city_name,
substr(t.code, 0, 6) || '000000' county_code,
(select name from DIVISIONS where substr(t.code, 0, 6) || '000000' =code) county_name,
substr(t.code, 0, 9) || '000' town_code,
(select name from DIVISIONS where substr(t.code, 0, 9) || '000' =code) town_name,
substr(t.code, 0, 12) vallige_code,
(select name from DIVISIONS where substr(t.code, 0, 12) =code) vallige_name,
(case when T.Is_Check=1 then '已核对' when T.Is_Check=0 then '未核对' else '其他' end) is_check_show, nvl(HDJGRSXJ, 0) HDJGRSXJ, nvl(DJDHDRHS, 0) DJDHDRHS,
nvl(DJDHDRRS, 0) DJDHDRRS,
nvl(DJDCMXZRS, 0) DJDCMXZRS,
RESERVOIR_NAMES,
RESERVOIR_CODES,
RESERVOIR_CODE_COUNT from DIVISIONS T left outer join (
select
QR_VALLIGE_GROUP_CODE,
wm_concat(distinct RESERVOIR_NAME) RESERVOIR_NAMES,
wm_concat(distinct RESERVOIR_CODE) RESERVOIR_CODES,
count(distinct RESERVOIR_CODE) RESERVOIR_CODE_COUNT,
nvl(sum(HDJGRSXJ), 0) HDJGRSXJ,
nvl(sum(DJDHDRHS), 0) DJDHDRHS,
nvl(sum(DJDHDRRS), 0) DJDHDRRS,
nvl(sum(DJDCMXZRS), 0) DJDCMXZRS
from basedata_register_villager_gro
group by QR_VALLIGE_GROUP_CODE
) brvg on brvg.QR_VALLIGE_GROUP_CODE=t.code WHERE code like'45%' and jb<5 and NAME like '%' || :keyWord || '%' ) TT WHERE TT.TmpRow between 1 and 30