Yes, I know I need a join. Now to get the code right.
No, I didn't post to EE. After 25 years on the Internet, hopefully I
know better then to cross-post.
Jim D.
> Yes, I know I need a join. Now to get the code right.
SELECT .. FROM
(SELECT DISTINCT CVGE_BNFT_PLN_ID
FROM (SELECT ROW_NUMBER() OVER(PARTITION BY CVRGE_CDE_1
ORDER BY CVGE_PRCG_EFFV_DTE desc)
as rn,
CVRGE_CDE_1,
CVGE_BNFT_PLN_ID,
CVGE_PRCG_EFFV_DTE
FROM SCHEMA1.COVERAGE) AS X WHERE rn = 1) AS X
JOIN T ON X.CVRGE_CDE_1 = T.CVRGE_CDE_1;
> No, I didn't post to EE. After 25 years on the Internet, hopefully I
> know better then to cross-post.
Fascinating coincidence.
Cheers
Serge

Signature
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
jd_12345@yahoo.com - 19 Apr 2006 19:04 GMT
Perhaps I should have looked at your message earlier. After about 3
hours I came up with the solution below. I believe I tried your method
but the Command Editor kept saying it didn't recognize the reference
[UserID].X. I don't know why it picked up the UserID. I also tried
creating Views but I never got either syntax right. The following
seems to work:
SELECT DISTINCT TBL_NME, RD_TYP, STRT_DTE, END_DTE
FROM SCHEMA1.BENEFIT_TABLES
WHERE BNFT_PLN IN (SELECT DISTINCT CVGE_BNFT_PLN_ID
FROM (SELECT ROW_NUMBER() OVER(PARTITION BY CVRGE_CDE_1
ORDER BY CVGE_PRCG_EFFV_DTE desc) AS rn,
CVRGE_CDE_1,
CVGE_BNFT_PLN_ID,
CVGE_PRCG_EFFV_DTE
FROM SCHEMA1.COVERAGE) AS X WHERE rn = 1)
I think I'm over the stuff I'm unfamiliar with or had forgotten long
ago. Now I can concentrate on my area of expertise, WebSphere
DataStage TX.
Thanks again, Jim D.