I have built my query here thus far:
SELECT POLICYNUMBER, FPLAN, FEFFYY, FEFFMM, FEFFDD, FINSTP, CLIENTNUM, FIRSTNAME,
MIDNAME, LASTNAME, BIRTHDATE FROM PFCASBENE
INNER JOIN CMRELATN ON POLICYNUMBER = KEYFIELD1
INNER JOIN CMPERSON ON CLIENTNUM = CLIENTID
WHERE FPSFLG='I' OR FPSFLG='P' ORDER BY CLIENTNUM ASC
The FINSTP field has a single character for an insurance type code.
EDIT: POLICYNUMBER, FPLAN, FEFFYY, FEFFMM, FEFFDD, FINSTP are fields in PFCASBENE CLIENTNUM is a field in CMRELATN and FIRSTNAME, MIDNAME, LASTNAME, BIRTHDATE are from CMPERSON. I should have said that before.
I want to return the results if the client only has policies that the FINSTP='F'. If they have other policies that have FINSTP = 'X', 'V', etc, then I don't want any of the clients records in the results.
this query returns multiple rows since a client can have multiple policies. I can get results if I put FINSTP='F' in the WHERE clause, but that's not what I want. That returns all that are 'F'. I'm not sure what else I need to add to the where clause to tune this query to what I need it to do.
This is for a DB2 on an AS/400 system.
Any help would be greatly appreciated!
- Josh