Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forcing subquery in main query filter as optional even when data exists

Status
Not open for further replies.

kvenkata

Programmer
Jul 8, 2016
1
US
where ( PROJ = (SELECT NAME FROM SOURCE.MGMT WHERE NUM = '<P31>' and BUS_PARTNER = '<BP>') )

To do this in cognos:
I have taken Query 1:SELECT NAME FROM SOURCE.MGMT WHERE NUM = '<P31>' and PARTNER = '<BP>'
Filter usage :eek:ption for NUM='<P31>' and Required for PARTNER='<BP>'
Now in Query 2 which is main query for List report , I have taken filter usage as optional again and PROJ=[Query1].[Name].

SQL generated expected as below when NUM parameter is not entered :
select * from table where date='2016-01-01' and week='2016-07-01' and what ever users enter in prompt page which are all optional.

SQL generated is:
select * from table where date='2016-01-01' and week='2016-07-01' and PROJ=(select NAME from SOURCE.MGMT where PARTNER='<BP>'.

which is not correct.
Here what should I do to skip the PROJ=....filter in where clause all together when no NUM is entered by users.

Any suggestions please
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top