Teradata: Get quarter for specific date

teradata

When selecting the maximum date of a column how do I obtain which quarter that date falls into without using a CASE statement?

Best Answer

Option 1: You can create a reference table (Month, Quarter) and you can extract month from your date column and join with it. (Joining this table won't affect performance as PI will be month)

Mth| Quarter
1  | 1
2  | 1
3  | 1
4  | 2
5  | 2
6  | 2
7  | 3 
8  | 3
9  | 3
10 | 4
11 | 4
12 | 4

Option 2: Use a logic as (2+Month)/3 as in

SELECT FLOOR((2+EXTRACT(MONTH FROM DATE_CLM))/3)