If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > db2 SQL Query

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-20-04, 12:49
antodomnic antodomnic is offline
Registered User
 
Join Date: Mar 2003
Posts: 69
db2 SQL Query

Hi,
I am running db2 v 7.2 under OS 390. I need to perform a sql query which satisfy my bellow requirement.

Have a table with fields appNo, appTimeStamp,appStatus

and has fields like,

appNo appTimestamp appStatus

1 2004-04-04-12.00.00 START
1 2004-04-04-12.04.00 COMPLETE
1 2004-04-04-12.12.00 HIRED

has any app numbers with like the above status..


My query is to fetch the records,

1. Select count of all appNo's (distinct) which the appTimestamp should be less than 4 minutes for the appStatus between "START" and "COMPLETE".

Any thoughts?
Reply With Quote
  #2 (permalink)  
Old 07-20-04, 13:16
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
SELECT DISTINCT (a.appNo)
FROM table-name a
WHERE a.status = 'START'
AND exists
(SELECT b.appNo
FROM table-name b
WHERE b.appNo = a.appNo
AND b.status = 'COMPLETE'
AND (b.appTimestamp - 4 minutes) < a.appTimestamp )
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On