Teradata SQL?

Database
Enthusiast

Teradata SQL?

how can I merge these two sql in to one query?

SELECT MONTH_BGN_DATE 

 FROM MONTHDAY_DIM 

 WHERE MONTHDAY_KEY = ADD_MONTHS(DATE , -4)) 

 SELECT  MONTH_END_DATE 

 FROM MONTHDAY_DIM WHERE 

 MONTHDAY_KEY = ADD_MONTHS(DATE , -3)) 

thanks.

Tags (3)
3 REPLIES
Senior Apprentice

Re: Teradata SQL?

Of course:

SELECT MONTH_BGN_DATE 
FROM MONTHDAY_DIM
WHERE MONTHDAY_KEY = ADD_MONTHS(DATE , -4)
OR MONTHDAY_KEY = ADD_MONTHS(DATE , -3)

If these are your actual queries, the 2nd closing parens "ADD_MONTHS(DATE , -3))" seems to indicate it's an excerpt from a more complex statement.

Dieter

Enthusiast

Re: Teradata SQL?

I want both MONTH_END_DATE and  MONTH_BGN_DATE.

thanks.

Senior Apprentice

Re: Teradata SQL?

Sorry,

i didn't notice it was different columns.

Simply UNION ALL both selects.

Dieter