페이지 쿼리
SELECT
ct_idx,
ct_class, dbo.GET_CODENAME('CTC',ct_class) as ct_classToKr ,
ct_setFlag, dbo.GET_CODENAME('CTS',ct_setFlag) as ct_setFlagToKr,
ct_bidFlag, dbo.GET_CODENAME('CTB',ct_bidFlag) as ct_bidFlagToKr,
ct_title, ct_dept_no, ct_dept_name, isused,
hit, convert(varchar(10),join_date,121) as join_date
FROM TBE_CONTRACT where ct_idx in (
SELECT
TOP $ent.rowSize
ct_idx
FROM (
SELECT
TOP $ent.currentSize
ct_idx, $ent.orderBy
FROM
TBE_CONTRACT
WHERE
1=1
AND pid = $ent.pid
#if($ent.used != "")
AND isused = $ent.used
#end
#if($ent.isdel != "")
AND isdel = $ent.isdel
#end
#if($ent.funcII != "")
AND ct_dept_no in(select ucode from dbo.GET_SUBDEPTCODE(#$ent.funcII::#))
#end
#if($ent.rsType != "" && $ent.rsKey!="")
AND $ent.rsType LIKE '%$ent.rsKey%'
#end
#if($ent.startDate != "" && $ent.endDate != "")
and left(join_date,10) between #$ent.startDate::# and #$ent.endDate::#
#end
and left(join_date,10)>=convert(varchar(4),dateadd(year, -2, getdate()),121)+'-01-01'
ORDER BY
$ent.orderBy $ent.cendingBy ,
ct_idx $ent.cendingBy
) scan
ORDER BY
scan.$ent.orderBy $ent.cendingIn ,
scan.ct_idx $ent.cendingIn
)
ORDER BY
$ent.orderBy $ent.cendingBy ,
ct_idx $ent.cendingBy