Use Of System Calendar in Teradata

Day to day work we need to write SQL queries with DATE . Teradata has inbuilt utility, we can use it to know useful information about DATE.

SYS_CALENDAR.CALENDAR

CALENDER is a view, and we would like to why we need to use it. If we want to know DATE attributes between 1900 to 2100 , we can use this utility.

Let me give different SQL Queries:

SELECT DAY_OF_WEEK,CALENDAR_WEEK
FROM SYS_CALENDAR.CALENDAR
WHERE CALENDAR_DATE = '1960-05-01';

Other way we can use it as:

CREATE VIEW Today AS (
SELECT *
FROM SYS_CALENDAR.Calendar
WHERE SYS_CALENDAR.Calendar.calendar_date = DATE
);
Just, we are creating another view as "today''. This can be used in Data warehousing projects. This is particularly useful in OLAP environments where it is common to request values aggregated by weeks, months, year-to-date, years, and so on.

Comments

Popular posts from this blog

SQL for Quantile Function in Teradata

3 Uses of SAMPLE function in Teradata

All You Need NULL Value Functions