728x90
반응형

LAG 함수

이전 행(ROW)의 데이터 가져오기

LAG(REGION_ID) OVER (ORDER BY REGION_ID)

SELECT  STUDENT_ID,
        STUDENT_NAME,
        LAG(STUDENT_ID) OVER (ORDER BY STUDENT_ID) 이전행ID,
        LAG(STUDENT_NAME) OVER (ORDER BY STUDENT_ID) 이전행NAME
FROM    STUDENT
ORDER BY STUDENT_ID

 

LEAD 함수

다음 행(ROW)의 데어터 가져오기

LEAD(REGION_ID) OVER (ORDER BY REGION_ID)

SELECT  STUDENT_ID,
        STUDENT_NAME,
        LEAD(STUDENT_ID) OVER (ORDER BY STUDENT_ID) 다음행ID,
        LEAD(STUDENT_NAME) OVER (ORDER BY STUDENT_ID) 다음행NAME
FROM    STUDENT
ORDER BY STUDENT_ID
반응형
복사했습니다!