Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2008
    Posts
    1

    Unanswered: 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

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    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

  3. #3
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •