Skip to Content
0
Former Member
Oct 19, 2011 at 06:35 PM

ADD COMMAND PART II

28 Views

Ian,

I used this and works great! Could you or someone help me to figure out how to link the Trip table to multiple tables. Like you said I don't want to add this query to other tables manually as it affects my report's performance.

I have 5 other tables I would like to link using LEFT OUTER JOIN to the Trip Table. I tried a few other ways that I researched online but none work.

SELECT *

FROM "AS400"."MTMODBC"."#MTMTRP" "_MTMTRP",

LEFT OUTER JOIN (

SELECT CHGTRP, CHGFCD, Max(CHGDTE) As Max_CHGDTE, Max(CHGTIM) As Max_CHGTIM

FROM "AS400"."MTMODBC"."#MTMTCHG" "_MTMTCHG"

WHERE CHGFCD= '076'

GROUP BY CHGTRP, CHGFCD

) C1

ON

TRIP#=CHGTRP

WHERE TINSCD= '0342' and

(TRPFLG Like 'S%' OR

TRPFLG in ('X1','X2','X3')) and

TREASC not in ('53','81') and

TAPTDT>=20110401 and

TAPTDT<=20110630

Appreciate your help!

Thanks!

Achett13