Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2004
    Posts
    7

    Unanswered: Complex query left join

    Hi,

    I have this query in Sybase which need to be migrated on DB2.

    How will be in DB2 this query ? Please help!
    SELECT
    a.*
    FROM
    ( SELECT o.business, o.br as br ,o.ord as ord, d.trde as trde
    FROM table e, table tf, table o, table d,

    WHERE o.business = '2006-01-04'
    AND o.source = '7'
    AND e.exec *= tf.exec
    AND e.exec *= tf.exec
    AND e.as *= tf.as
    AND o.ord *= e.ord
    AND o.ord *= e.ord
    AND o.ord *= e.ord
    AND o.acct *= d.acct
    AND o.acct_no *= d.acct_no

    ) a, table bd, table bdt
    WHERE a.br *= bd.br
    AND a.ord *= bdt.bra
    AND (a.trde not in ('a','x','w') OR a.trde is null)
    ;

    Thanks.

  2. #2
    Join Date
    Apr 2004
    Posts
    54
    use LEFT OUTER JOIN instead of *=

  3. #3
    Join Date
    Jul 2004
    Posts
    7

    mara

    Can you please send me the query using left join ?

    Thanks.

  4. #4
    Join Date
    Mar 2005
    Posts
    7
    should be something like

    select ...
    from (...) a
    left outer join bd on a.br=bd.br
    left outer join bdt on a.ord=bdt.bra
    where (a.trde not in ('a','x','w') OR a.trde is null)

  5. #5
    Join Date
    Jul 2004
    Posts
    7

    complex query

    Hi,
    Thank you for your answer.

    Here is the issue


    where (a.trde not in ('a','x','w') OR a.trde is null)

    Because trde is a column from an unpreserved table the condition is not correct. If this query is ran it on Sybase and DB2 the result set is different.

    So, which can be the solution ?

Posting Permissions

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