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

Db2 Date compare year (min(startdate) > year in other tab


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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

Moderator Emeritus


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

PostPosted: Fri Mar 20, 2009 8:14 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Compare only first records of the fil... SYNCSORT 7
Search our Forums:

Back to Top