Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Check crossing time periods between rows

Tobias ArnholdFeb 11 2014 — edited Feb 11 2014

Hi,

I have the problem creating a select to check between crossing time periods.

This is my table

CREATE TABLE "T_PLAN"

(  "TRAIN_NO" NUMBER,

    "TIME_FROM" VARCHAR2(5),

    "TIME_UNTIL" VARCHAR2(5),

    "RAIL_NO" NUMBER

) ;

TRAIN_NO    TIME_FROM    TIME_UNTIL    RAIL_NO

172    07:06    15:50    1

120    07:33    15:41    2

229    07:56    14:52    3

217    15:05    18:47    1

189    16:10    19:53    2

185    16:10    19:53    3

181    20:10    23:53    2

142    29:14    23:32    3

I want to check if my train with number 172 is crossing another row with the same RAIL_NO.

In that case train number 217 is hitting the same time period as 172 does. Because: 15:05 <= 15:50

The output I need:

TRAIN_NO    TIME_FROM    TIME_UNTIL    RAIL_NO CHECK_ROW

172    07:06    15:50    1     UNVALID

120    07:33    15:41    2     VALID

229    07:56    14:52    3     VALID

217    15:05    18:47    1     UNVALID

189    16:10    19:53    2     VALID

185    16:10    19:53    3     VALID

181    20:10    23:53    2     VALID

142    20:14    23:32    3     VALID

Thanks for your support.

Cheers Tobias

This post has been answered by Frank Kulash on Feb 11 2014
Jump to Answer

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Mar 11 2014
Added on Feb 11 2014
9 comments
4,023 views