COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: cbyrne on 14 Sep 2009 06:20:06 AM

Title: Joining two tables using a full join statement
Post by: cbyrne on 14 Sep 2009 06:20:06 AM
Hello i am trying to join two tables in cognos/report studio and below is the sql code i have entered but i keep getting an error missing keyword.  Can anybody spot a mistake in the below code.

SELECT a.evt_code, b.ect_labor
FROM r5events a
FULL JOIN r5eventcosts b
WHERE r5events a.a.evt_code = r5eventcosts b.b.ect_labor


Many Thanks
Title: Re: Joining two tables using a full join statement
Post by: blom0344 on 14 Sep 2009 08:07:48 AM
SELECT a.evt_code, b.ect_labor
FROM r5events a
FULL JOIN r5eventcosts b
WHERE r5events a.a.evt_code = r5eventcosts b.b.ect_labor

SELECT a.evt_code, b.ect_labor
FROM r5events a
FULL JOIN r5eventcosts b
on a.evt_code = b.ect_labor

syntax-wise . However only fetching the join object is pretty useless (a union would then be better)



SELECT coalesce(a.evt_code, b.ect_labor), a.[somefield],b.[otherfield]
FROM r5events a
FULL JOIN r5eventcosts b
on a.evt_code = b.ect_labor

would make more sense..
Title: Re: Joining two tables using a full join statement
Post by: cbyrne on 14 Sep 2009 10:29:15 AM
Yes i agree this would make more sense to use a union.  I have tried this code and it now works thank you very much for you response.

Many Thanks

Chris