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 > SELF JOIN with count condition

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-05-08, 13:23
skm skm is offline
Registered User
 
Join Date: Mar 2008
Posts: 1
SELF JOIN with count condition

I am requesting sql self join ideas from the experts.

PROC_ID UID PROC_TIMESTAMP
-----------------------------------------------------------------------
706 1 2007-02-06 14:41:12.29
706 2 2007-02-06 17:31:02.191
706 3 2007-02-27 11:42:31.961
901 1 2008-02-29 14:29:19.264
902 2 2008-02-29 14:36:58.62
902 2 2008-02-29 14:37:31.388

PROC_ID = 706 dentotes the record with UID = 1,2,3 should be processed
PROC_ID = 901 dentotes the record with UID = 1 was processed successfully
PROC_ID = 902 dentotes the record with UID = 2 was processed with ERROR

I am looking for a query that filters out the SUCCESSFULLY processed record with UID 1 and the records that has been processed with ERROR 'n' number of times.
Here the 'n' = TWO TIMES.

According to this test case the query should output following record with UID = 3
706 3 2007-02-27 11:42:31.961

Please can anyone assist with the SQL query.

Thanks a lot people
Reply With Quote
  #2 (permalink)  
Old 03-05-08, 16:22
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
I am sorry, I do not understand what you want. What constitutes an "Error"? For that matter what constitutes a "success"? This information is not readily apparent.

Also provide you DB2 version and OS. What is the query you are trying?
What it the entire DDL for the table?

Andy
Reply With Quote
  #3 (permalink)  
Old 03-06-08, 04:57
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
You should reconsider your design because of the reasons Andy mentioned. It seems that you "encrypt" semantics in numbers instead of modeling it properly.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
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