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
 
Db2 Date compare year (min(startdate) > year in other tab

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
tanguduk
Warnings : 1

New User


Joined: 29 Aug 2005
Posts: 14

PostPosted: Fri Mar 20, 2009 1:49 pm    Post subject: Db2 Date compare year (min(startdate) > year in other tab
Reply with quote

Hi ,

I have start date in one table and year in one table i have to compare year (min(startdate) > year in other table . Please let me know how can i compare this .

this is my query
Code:
 SELECT A.EMP_NR,A.LT_SS_PE_DTE,                                           
 MAX(B.PH_STRT_DTE),B.PH_END_DTE,B.PH_PEP_TYP,                             
 B.PH_PAS_PLN_NR,A.LT_BIS_YEAR  FROM                                       
 AAPROD.PASR230A_LIFETIME A,                                               
 AAPROD.PASR240A_PEPHIST B WHERE A.EMP_NR= B.EMP_NR AND                   
 --ELECT  MIN(C.PH_STRT_DTE) FROM                                         
--APROD.PASR240A_PEPHIST C   WHERE A.EMP_NR= C.EMP_NR AND                 
 B.PH_PEP_TYP ='I' AND                                                     
 B.PH_PAS_PLN_NR IN (90,94,95) GROUP BY A.EMP_NR,A.LT_SS_PE_DTE,           
 B.PH_STRT_DTE,B.PH_END_DTE,B.PH_PEP_TYP, B.PH_PAS_PLN_NR,A.LT_BIS_YEAR   
 HAVING A.LT_SS_PE_DTE < MIN(B.PH_STRT_DTE) AND                           
 (YEAR(MIN(B.PH_STRT_DTE)) >   A.LT_BIS_YEAR)    AND                       
 ((DAYS (A.LT_SS_PE_DTE) - DAYS(MIN(B.PH_STRT_DTE)) > 28) OR               
 (DAYS (A.LT_SS_PE_DTE) - DAYS(MIN(B.PH_STRT_DTE)) <= -28));   


When I compare I am getting error
SQLCODE = -401, ERROR: THE OPERANDS OF AN ARITHMETIC OR COMPARISON
OPERATION ARE NOT COMPARABLE

Please suggest me ..
Back to top
View user's profile Send private message

anandinmainframe

Active User


Joined: 31 May 2007
Posts: 171
Location: India

PostPosted: Fri Mar 20, 2009 5:19 pm    Post subject: Reply to: Db2 Date compare year (min(startdate) > year in
Reply with quote

kiran kumar,
This is the problem i believe
Code:

(DAYS (A.LT_SS_PE_DTE) - DAYS(MIN(B.PH_STRT_DTE)) <= -28));


please remove the commented lines before you post and use code tags.
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Fri Mar 20, 2009 8:14 pm    Post subject:
Reply with quote

Hello,

Suggest you clone the query to the bare minimum needed to test the date comparison. If that does not work, post the small query (using the "Code" tag) along with the diagnostic info.
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Fri Mar 20, 2009 8:33 pm    Post subject:
Reply with quote

Code:
(YEAR(MIN(B.PH_STRT_DTE)) >   A.LT_BIS_YEAR)


YEAR(MIN(B.PH_STRT_DTE) would be an large integer what is the definition of A.LT_BIS_YEAR?
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 -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Compare VSAM files using DFSORT pshongal DFSORT/ICETOOL 5 Thu Nov 23, 2017 10:24 am
No new posts Fetching data from JHS as per the cur... arunsoods All Other Mainframe Topics 4 Wed Nov 22, 2017 1:54 pm
No new posts Compare and COPY using DFSORT pshongal DFSORT/ICETOOL 3 Fri Nov 17, 2017 9:49 am
No new posts Date in where clause - Windows Karthikeyan Subbarayan DB2 9 Wed Nov 15, 2017 9:07 pm
No new posts File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am

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