COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: sony on 21 Sep 2012 01:19:50 PM

Title: Subquery
Post by: sony on 21 Sep 2012 01:19:50 PM
How to get the below query in cognos report studion irrespective of joins in FM or do i have to change the join in FM :

Select a.* from a
left join b
on a.key = b.key
Where a.key not in (Select b.key from b)

????

Thanks,
sony
Title: Re: Subquery
Post by: tjohnson3050 on 21 Sep 2012 03:14:41 PM
create a separate query in Report Studio for the subquery (b.key), do not join the queries, then on both queries set the property 'allow cross joins' to yes.

After that, in the primary query, pull the data item b.key from the subquery.
Title: Re: Subquery
Post by: wyconian on 23 Sep 2012 04:01:50 PM
Hi

Looks like you want to get everything from a where it's not in b.  If that's what you want add a union query where one of the queries selects everything from a and the other selcts everything from b. Change the union icon to except.
Title: Re: Subquery
Post by: mrcool on 25 Sep 2012 09:07:58 PM
First All I don't think join is required in your example as below query will work the same

Select a.* from a

Where a.key not in (select key from b)

As tjohnson3050 suggested create one more query for getting b.key and apply detail filter in parent query
a.key <>b.key

Cheers,
MC