Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003
    Posts
    7

    Unanswered: Conditional Where Clause?

    Posted in the SQl board also, but thought there might be a DB2 specific function to help with this . . .

    Just found this forum and have learned a tremendous amount browsing around. I've got a problem I hope someone can help me with.

    Two tables, A and B. Need to join where A.site_id = B.site_id. Not a problem. Here is where the problem lies - Also need to add a condition if A.doc_status is not null then A.doc_status = B.status. If no records are found then use condition B.archive_flag = 'C'.

    Any suggestions? Using DB2 7.2 if that matters.

  2. #2
    Join Date
    Sep 2003
    Posts
    5

    Re: Conditional Where Clause?

    select a.*
    from
    a, b
    where
    a.site_id = b.site_id
    and ((a.doc_status is not null
    and a.doc_status = b.status)
    or
    (a.doc_status is null and B.archive_flag = 'C'))

    ??



    Originally posted by GTI337
    Posted in the SQl board also, but thought there might be a DB2 specific function to help with this . . .

    Just found this forum and have learned a tremendous amount browsing around. I've got a problem I hope someone can help me with.

    Two tables, A and B. Need to join where A.site_id = B.site_id. Not a problem. Here is where the problem lies - Also need to add a condition if A.doc_status is not null then A.doc_status = B.status. If no records are found then use condition B.archive_flag = 'C'.

    Any suggestions? Using DB2 7.2 if that matters.

Posting Permissions

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