IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

sql select


IBM Mainframe Forums -> HomeWorks & Requests
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
riteshsingh92

New User


Joined: 10 Nov 2009
Posts: 17
Location: India

PostPosted: Tue Nov 17, 2009 4:20 am
Reply with quote

H have written this sql to select records from different tables but its not getting the expected results when i added ,E.EMP_STATUS_IND AS STATUS from PROPOSED_INSURED table.
priveous it was working fine when i havent added PROPOSED_INSURED table.

please let me know What I'm doing wrong here?


SELECT
C.CONTRACT_NO AS POLICY_NUMBER
,C.ROLE_CD AS ROLE_CODE
,C.SUB_ROLE_CD AS SUB_ROLE_CODE
,A.ADDR_ID AS ADDRESS_ID
,A.LINE1_ADDR AS ADDRESS1
,A.LINE2_ADDR AS ADDRESS2
,A.LINE3_ADDR AS ADDRESS3
,A.CITY_ADDR AS CITY
,A.ST_ADDR AS STATECODE
,A.ZIP_ADDR AS ZIP
,A.CTRY_ADDR AS COUNTRY
,B.TAX_ID_NO AS SSN
,E.EMP_STATUS_IND AS STATUS
,E.OCCP_NAME AS OCCUPATION
FROM CLU.PERSON_ADDRESS A
,CLU.PERSON B
,CLU.CONT_PSN_REL C
,EQNBNDB.APPLICATION_STATUS D
,EQNBNDB.PROPOSED_INSURED E
WHERE D.AC_APP_NO IN
(SELECT D.AC_APP_NO FROM CLU.PERSON_ADDRESS A
,CLU.PERSON B
,CLU.CONT_PSN_REL C
,EQNBNDB.APPLICATION_STATUS D
,EQNBNDB.PROPOSED_INSURED E
WHERE
D.AC_APP_NO = C.CONTRACT_NO
AND C.CONTRACT_NO = E.FK_CONTR_POL_NO
AND C.ADDR_ID = A.ADDR_ID
AND C.FK_PERSON_PSN_ID = B.PSNID
AND A.ADDR_ID = B.PRIME_ADDR_ID
AND A.ZIP_ADDR LIKE '10022%'
AND C.ROLE_CD IN(1,2,8)
AND E.EMP_STATUS_IND IN ('Y','N')
AND D.AC_APPSTATUS_TXT IN('APPROVED','APPROVED'))
AND C.ROLE_CD IN(1,2,8) AND
D.AC_APP_NO = C.CONTRACT_NO
AND C.ADDR_ID = A.ADDR_ID
AND C.FK_PERSON_PSN_ID = B.PSNID
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Tue Nov 17, 2009 11:27 am
Reply with quote

What results are you getting with the additional table?
Back to top
View user's profile Send private message
riteshsingh92

New User


Joined: 10 Nov 2009
Posts: 17
Location: India

PostPosted: Tue Nov 17, 2009 9:28 pm
Reply with quote

I am getting Zero rows found can you please let me know weather I have placed condition for PROPOSED_INSURED table is correct in SQL. Thanks.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Tue Nov 17, 2009 9:49 pm
Reply with quote

You've added an additional restriction in the predicate of the subquery, so isn't it possible that there are no rows found? Also, please use BBCode (see FAQ) to make your code more readable.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> HomeWorks & Requests

 


Similar Topics
Topic Forum Replies
No new posts Dynamically pass table name to a sele... DB2 2
No new posts SELECT from data change table DB2 5
No new posts Select two different counts from SQL... DB2 6
No new posts Select a DB2 value in a specific deci... DB2 4
No new posts How can I select certain file dependi... JCL & VSAM 12
Search our Forums:

Back to Top