페이지 쿼리

DB/MSSQL 2019. 3. 22. 11:41

페이지 쿼리


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


'DB > MSSQL' 카테고리의 다른 글

dblink3  (0) 2019.04.02
dblink  (0) 2019.04.02
dblink2  (0) 2019.03.22
페이지 쿼리2  (0) 2019.03.22
DBLINK  (0) 2019.03.21
블로그 이미지

마크제이콥스

초보 개발자의 이슈및 공부 내용 정리 블로그 입니다.

,