다음값1 [Oracle/오라클] LEAD() 다음 레코드 값, LAG() 이전 레코드 값 조회 LEAD(필드명) OVER (PARTITION BY 그룹필드명 ORDER BY 정렬필드 명) ★ ORDER BY 필수 SELECT TRAIN_NO, RUN_ORDR, STATION_NM, NVL(LEAD(STATION_NM) OVER(PARTITION BY TRAIN_NO ORDER BY RUN_ORDR),' ') NEXT_STATION FROM TB_TRAIN_TM; LAG(필드명) OVER (PARTITION BY 그룹필드명 ORDER BY 정렬필드 명) SELECT TRAIN_NO, RUN_ORDR, STATION_NM, NVL(LAG(STATION_NM) OVER(PARTITION BY TRAIN_NO ORDER BY RUN_ORDR),' ') PREV_STATION FROM TB_TRAIN_TM; 2021. 10. 19. 이전 1 다음