Teradata equivalent for lead and lag function of oracle
I believe you can take the following SQL as a basis and modify it to meet your needs:
SELECT CALENDAR_DATE , MAX(CALENDAR_DATE) OVER(PARTITION BY 1 ORDER BY CALENDAR_DATE ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) AS Lag_ --Yesterday , MIN(CALENDAR_DATE) OVER(PARTITION BY 1 ORDER BY CALENDAR_DATE ROWS BETWEEN 1 FOLLOWING AND 1 FOLLOWING) AS Lead_ --TomorrowFROM SysCalendar.CALENDARWHERE year_of_calendar = 2011 AND month_of_year = 11
NULL is returned when there is no record before or after and can be addressed with a COALESCE as necessary.
EDIT In Teradata 16.00 LAG/LEAD functions were introduced.