|
|
Archives of the TeradataForum
Message Posted: Wed, 21 Sep 2005 @ 09:58:34 GMT
Subj: | | Re: DW/ Query Man SQL Help with Max Version Please |
|
From: | | Vinod Sugur |
Hi,
SELECT COUNT (*)
FROM VMVMT_CYCLE A JOIN EVENT_ B ON
A.EQP_INIT = B.CAR_INIT AND
A.EQP_NUMB = B.CAR_NUMB AND
A.BGN_EVT_DT = B.EVT_DT AND
A.BGN_EVT_CD = B.EVT_CD AND
A.ORIG_STN_333 = B.STN_333
JOIN VWBM C ON
B.WB_ID = C.WB_ID
JOIN (SELECT WB_ID, MAX(WB_VRSN)
FROM VWBM_CITY_CUST
GROUP BY WB_ID) D ON
D.WB_ID = C.WB_ID
We can still optimize the query further for the alias D.
I hope this helps.
~vinod
| |