0

私は、授業日ごとにクラスを返す select ステートメントに取り組んでいます。サイクルが最初からやり直すまでに 4 日間の授業日があります。(例: 月曜日 = Day1、火曜日 = Day2...木曜日 = Day4、金曜日 = Day1..など)

一部の学生は、特定の日に 1 ピリオドを取得する場合があります。その場合、その日/ピリオドの組み合わせに空きスペースを表示する必要があります。

現時点では、select ステートメントは値を持つ日のみを返します。

例:

            Day 1    Day 2    Day 3    Day 4
Period 1    class    class    off      class
Period 2    class    class    class    off
Period 3    off      class    class    class
Period 4    class    off      class    class

私が達成しようとしているのは、特定の日にオフになっている期間の代わりに、select ステートメントが空の行 (null 値を持つ) を返すようにすることです。日を唯一の値として Unions を追加してみました。

最初の 3 行を取得し、次に他の 4 行を取得しているため、これは機能しませんが、実際に必要なのは最初の 3 行 (たとえば、1、3、4 日) と最後の結合行 (たとえば、 2日目)その場合、その後、当日までに注文できます。

これどうやってするの?交差を使用する必要がありますか?..または交差の反対?また、これは Oracle データベース用です。

選択ステートメント:

select spct.course_code||'-'||spct.course_section as course,t.school_cycle_day as jour,p.legal_first_name,p.legal_surname,sc.room_no
from   student_program_class_tracks@trl spct,class_meetings@trl cm,school_classes@trl sc,persons@trl p,timeslots@trl t,school_timeline_periods@trl tsp
where  spct.school_code=cm.school_code
and    spct.school_code=sc.school_code
and    spct.school_code=t.school_code
and    spct.school_code=tsp.school_code
and    spct.school_year=cm.school_year
and    spct.school_year=sc.school_year
and    spct.school_year=t.school_year
and    spct.school_year=tsp.school_year
and    t.school_year_track=tsp.school_year_track
and    t.school_timeline_code=tsp.school_timeline_code
and    t.school_period=tsp.school_period
and    spct.class_code=cm.class_code
and    spct.class_code=sc.class_code
and    sc.reporting_teacher=p.person_id
and    cm.block=t.block
and    spct.school_code='73'
and    spct.school_year='20122013'
and    spct.person_id='000170629'
and    cm.semester='2'
and    cm.term='1'
and    t.school_period='1'
and    ((spct.start_date <= sysdate and spct.end_date >= sysdate) or spct.demit_indicator='0')
--order by t.school_cycle_day

UNION

SELECT '','1','','','' from DUAL

UNION

SELECT '','2','','','' from DUAL

UNION

SELECT '','3','','','' from DUAL

UNION

SELECT '','4','','','' from DUAL;

出力:

Course         Jour    Legal_first_name   Legqal_surname     Room_no
PPL4OO-03      2       François           Belle-Isle     1-139
SBI4UU-02      4       Louise             Bérubé             1-155
TFC4EE-02      3       Gino               Proulx             1-127
           1            

ご協力いただきありがとうございます。

4

1 に答える 1