Results 1 to 2 of 2

Thread: Overlaps question

  1. #1
    Join Date
    Jul 2011
    Posts
    2

    Question Overlaps question

    Hello,

    I have a request for the pro in SQL.

    TableA(id)
    +-----------TableB(id, id_tableA, start, stop)

    I try to search the record of TableA
    where there is no record in TableB that have overlaped period.

    Ex data:
    if by exemple 2 record in tableB have overlaping date (look at http://www.orafaq.com/node/2067) the record associated (ForeignKey) in tableA should be excluded from the result.

    Thanks for help.

  2. #2
    Join Date
    Jul 2011
    Posts
    2

    Thumbs up

    Problem fixed:

    FROM tableB
    inner join
    tableB2
    on tableB.ID = tableB2.ID
    --Not supported by db2
    --and (tableB.start, tableB.stop) OVERLAPS (tableB2.start, tableB2.stop)
    --replaced by following tests
    and ( tableB.start BETWEEN tableB2.start AND tableB2.stop
    OR tableB.stop BETWEEN tableB2.start AND tableB2.stop
    OR tableB2.start BETWEEN tableB.start AND tableB.stop
    OR tableB2.stop BETWEEN tableB.start AND tableB.stop
    ),
    tableA
    where tableA.ID = tableB.idTableA

    Thanks anyway.

Posting Permissions

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