128 | | {{{ |
129 | | SELECT se.*, ce.* |
130 | | FROM subject_event se |
131 | | JOIN calendar_event ce ON se.calendar_event_id = ce.calendar_event_id |
132 | | WHERE ce.event_type = 'Exam' |
133 | | AND ce.event_start_time >= CURRENT_TIMESTAMP |
134 | | AND ce.event_start_time <= CURRENT_TIMESTAMP + INTERVAL '7 days'; |
135 | | |
136 | | }}} |
| 127 | |
| 128 | {{{ |
| 129 | DECLARE correct_student_id INT; |
| 130 | SET correct_student_id = 11111; |
| 131 | |
| 132 | SELECT |
| 133 | ce.event_name, |
| 134 | sat.subject_name, |
| 135 | ce.event_start_time, |
| 136 | ce.event_end_time |
| 137 | FROM |
| 138 | subject_event AS se |
| 139 | JOIN |
| 140 | calendar_event AS ce ON se.calendar_event_id = ce.calendar_event_id |
| 141 | JOIN |
| 142 | subject_at_term AS sat ON se.term_subject_id = sat.term_subject_id |
| 143 | AND se.term_type = sat.term_type |
| 144 | AND se.starting_year = sat.starting_year |
| 145 | AND se.finishing_year = sat.finishing_year |
| 146 | AND se.student_id = sat.student_id |
| 147 | JOIN |
| 148 | non_repeating_event AS nre ON ce.calendar_event_id = nre.calendar_event_id -- Corrected table name |
| 149 | WHERE |
| 150 | ce.event_type = 'Exam' |
| 151 | AND se.student_id = correct_student_id |
| 152 | AND nre.event_date >= CURRENT_DATE |
| 153 | AND nre.event_date <= CURRENT_DATE + INTERVAL '7 days' |
| 154 | ORDER BY |
| 155 | nre.event_date, |
| 156 | ce.event_start_time; |
| 157 | }}} |
| 158 | |