Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
sql select

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> HomeWorks & Requests
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    Post subject: sql select
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    Post subject:
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> HomeWorks & Requests All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts Select numeric portion from CHAR data... balaji81_k DB2 6 Sat Aug 19, 2017 1:51 am
No new posts SQL - select data available in index Nileshkul DB2 3 Mon Jun 26, 2017 1:30 am
No new posts Two Selects in a single select query Rohit Umarjikar DB2 1 Fri Nov 04, 2016 8:46 pm
No new posts Select first 2 group data vice_versa DFSORT/ICETOOL 10 Mon Jun 13, 2016 2:21 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us