All Forums Database
TcognosD 11 posts Joined 04/13
30 Jun 2013
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.

 

dnoeth 4628 posts Joined 11/04
01 Jul 2013

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

Dieter

TcognosD 11 posts Joined 04/13
09 Jul 2013

I want both MONTH_END_DATE and  MONTH_BGN_DATE.
thanks.

dnoeth 4628 posts Joined 11/04
09 Jul 2013

Sorry,
i didn't notice it was different columns.
Simply UNION ALL both selects.
Dieter
 
 

Dieter

You must sign in to leave a comment.