Forum Stats

  • 3,734,267 Users
  • 2,246,934 Discussions
  • 7,857,216 Comments

Discussions

SQL for displaying time-periods in a Gantt Chart

Rudolf Noe
Rudolf Noe Member Posts: 11 Red Ribbon
edited May 6, 2015 3:59AM in SQL

Hello,

I have the following problem:

I have a table with time-periods, which should be displayed in a Gantt Chart with the following constraints:

1. The periods should be displayed without intersections

2. The number of lines in the Gantt Chart should be irreducible.

Here is how the Table looks like

create table timeperiod(

  id number primary key,

  start_date date,

  end_date date,

  .....

}

The result should look like this

                     P1                  P4

Line1: |---------------||----------------------|

                            P2                P6

Line2:         |----------------| |---------------|

                               P3                 P7

Line3:               |----------|     |--------------|

                                           P5

Line4:                          |---------------|

What need's to be calculated is the line number on which the period.is displayed.

The pseudo-algorithm looks like that:

1. Order the periods according the start-date (ascending)

2. Give the first period the line-no 1

2. Iterate of the rest of the periods (in order of start-date)

    For every period find the minium line number where the the end-date of the latest period in that line is smaller than the start-date of the current period

    If none is found increase the number lines by one

I assume this can be solved with the model clause, but how :-)

Thanks a lot!

Rudolf

Sign In or Register to comment.