Q
Problem solve Get help with specific problems with your technologies, process and projects.

Using OR instead of UNION in a subselect

I created the following SQL that is to be embedded into a DB2 program:
SELECT * FROM HACPRP.EQ_POOL_ACT_VIEW
WHERE ACTVTY_DT IN
( SELECT ACTVTY_DT FROM 
  HACPRP.EQ_POOL_ACT_VIEW 
  WHERE SUBSTR(ACTVTY_DT,5,2) < '03' 
 UNION 
  SELECT ACTVTY_DT FROM 
  HACPRP.EQ_POOL_ACT_VIEW 
  WHERE SUBSTR(ACTVTY_DT,1,2) < '09' 
  AND SUBSTR(ACTVTY_DT,5,2) = '03' 
 UNION 
  SELECT ACTVTY_DT FROM 
  HACPRP.EQ_POOL_ACT_VIEW 
  WHERE SUBSTR(ACTVTY_DT,3,2) < '29' 
  AND SUBSTR(ACTVTY_DT,1,2) = '09' 
  AND SUBSTR(ACTVTY_DT,5,2)= '03' );

The reason I have to do it like this is that someone created the table with ACTVTY_DT as CHAR(06) instead of DATE....

Why does the above SQL not run? It states that it is not suitable for the DB2 Manager. My aim is to simply select a list of entries that are less than the date given on the JCL job.

This was last published in October 2003

Dig Deeper on Oracle and SQL

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide.com

SearchDataCenter

SearchContentManagement

SearchHRSoftware

Close