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

SQL query causing timeout


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
prasun dhara

New User


Joined: 01 Mar 2008
Posts: 49
Location: kolkata

PostPosted: Wed Mar 21, 2012 5:52 pm
Reply with quote

Requiremnt :
Need to find out all the event no whose first 4 bytes are same but last 2 bytes are different

Table A
Code:
event no
123455
223455
223455
123456
672744
672746

Expected out put

Code:
123455
123456
672744
672746


We have written a query BUT THIS IS GETTING TIME OUT abend

Code:
SELECT DISTINCT A.EVN FROM DB2.TABLEA A                 
WHERE EXISTS                                               
   ( SELECT 1 FROM DB2.TABLEA B                           
     WHERE A.EVN BETWEEN B.EVN AND LEFT(B.EVN,4)||'99' 
       AND A.EVN > B.EVN)                                 
WITH UR;
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Mar 21, 2012 6:18 pm
Reply with quote

can't test, but:
Code:
SELECT A.EVN
FROM TABLE A
    ,TABLE B
WHERE LEFT(A.EVN,4) = LEFT(B.EVN,4)
  AND A.EVN <> B.EVN
GROUP BY A.EVN
Back to top
View user's profile Send private message
prasun dhara

New User


Joined: 01 Mar 2008
Posts: 49
Location: kolkata

PostPosted: Fri Mar 23, 2012 9:46 am
Reply with quote

Cost of query is even more for this.

Code:
SELECT A.EVN
FROM TABLE A
    ,TABLE B
WHERE LEFT(A.EVN,4) = LEFT(B.EVN,4)
  AND A.EVN <> B.EVN
GROUP BY A.EVN


Can you please suggest some other for which cost of query will be less other wise job will get ebended with timeout
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 RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Issue with EXEC CICS QUERY SECURITY c... CICS 6
Search our Forums:

Back to Top