Topic
1 reply Latest Post - ‏2013-11-04T16:23:04Z by Jotac
rweworld
rweworld
1 Post
ACCEPTED ANSWER

Pinned topic DB2 - SQL - recursive query

‏2013-10-25T17:39:46Z |

Hi,

I'm new to database world. I need help in DB2 query to find out projects which are completed based on their task status.

Here is data:


ProjID TaskID   Status
P1      T11       Complete
P1      T12       Complete
P1      T13       Complete
P2      T21       Complete
P2      T22       Active
P3      T31       Active
P4      T41       Complete
P4      T42       Active
P4      T43       Complete
P4      T44       Active
P5      T51       Complete
P6      T61       Active
P6      T62       Active
P7      T71       Complete
P7      T72        Complete

Out put should display list of projects which are completed. Based on it's all task completed.

Output
ProjID
P1
P5
P7


What kind of query can give me such result?

Thanks for your help,

RR

Updated on 2013-10-25T17:40:04Z at 2013-10-25T17:40:04Z by rweworld
  • Jotac
    Jotac
    82 Posts
    ACCEPTED ANSWER

    Re: DB2 - SQL - recursive query

    ‏2013-11-04T16:23:04Z  in response to rweworld

    select distinct ProjID from proj t1 where not exists (select * from proj t2 where t1.ProjID = t2.ProjID and status <> 'Complete')