37 | | WHEN re.event_week_day = 'TUESDAY' THEN date_trunc('week', CURRENT_DATE) + interval '1 day'::DATE |
38 | | WHEN re.event_week_day = 'WEDNESDAY' THEN date_trunc('week', CURRENT_DATE) + interval '2 days'::DATE |
39 | | WHEN re.event_week_day = 'THURSDAY' THEN date_trunc('week', CURRENT_DATE) + interval '3 days'::DATE |
40 | | WHEN re.event_week_day = 'FRIDAY' THEN date_trunc('week', CURRENT_DATE) + interval '4 days'::DATE |
41 | | WHEN re.event_week_day = 'SATURDAY' THEN date_trunc('week', CURRENT_DATE) + interval '5 days'::DATE |
42 | | WHEN re.event_week_day = 'SUNDAY' THEN date_trunc('week', CURRENT_DATE) + interval '6 days'::DATE |
| 38 | WHEN re.event_week_day = 'TUESDAY' THEN (date_trunc('week', CURRENT_DATE) + INTERVAL '1 day')::DATE |
| 39 | WHEN re.event_week_day = 'WEDNESDAY' THEN (date_trunc('week', CURRENT_DATE) + INTERVAL '2 days')::DATE |
| 40 | WHEN re.event_week_day = 'THURSDAY' THEN (date_trunc('week', CURRENT_DATE) + INTERVAL '3 days')::DATE |
| 41 | WHEN re.event_week_day = 'FRIDAY' THEN (date_trunc('week', CURRENT_DATE) + INTERVAL '4 days')::DATE |
| 42 | WHEN re.event_week_day = 'SATURDAY' THEN (date_trunc('week', CURRENT_DATE) + INTERVAL '5 days')::DATE |
| 43 | WHEN re.event_week_day = 'SUNDAY' THEN (date_trunc('week', CURRENT_DATE) + INTERVAL '6 days')::DATE |
54 | | WHEN re.event_week_day = 'TUESDAY' THEN date_trunc('week', CURRENT_DATE) + interval '1 day'::DATE |
55 | | WHEN re.event_week_day = 'WEDNESDAY' THEN date_trunc('week', CURRENT_DATE) + interval '2 days'::DATE |
56 | | WHEN re.event_week_day = 'THURSDAY' THEN date_trunc('week', CURRENT_DATE) + interval '3 days'::DATE |
57 | | WHEN re.event_week_day = 'FRIDAY' THEN date_trunc('week', CURRENT_DATE) + interval '4 days'::DATE |
58 | | WHEN re.event_week_day = 'SATURDAY' THEN date_trunc('week', CURRENT_DATE) + interval '5 days'::DATE |
59 | | WHEN re.event_week_day = 'SUNDAY' THEN date_trunc('week', CURRENT_DATE) + interval '6 days'::DATE |
| 57 | WHEN re.event_week_day = 'TUESDAY' THEN (date_trunc('week', CURRENT_DATE) + INTERVAL '1 day')::DATE |
| 58 | WHEN re.event_week_day = 'WEDNESDAY' THEN (date_trunc('week', CURRENT_DATE) + INTERVAL '2 days')::DATE |
| 59 | WHEN re.event_week_day = 'THURSDAY' THEN (date_trunc('week', CURRENT_DATE) + INTERVAL '3 days')::DATE |
| 60 | WHEN re.event_week_day = 'FRIDAY' THEN (date_trunc('week', CURRENT_DATE) + INTERVAL '4 days')::DATE |
| 61 | WHEN re.event_week_day = 'SATURDAY' THEN (date_trunc('week', CURRENT_DATE) + INTERVAL '5 days')::DATE |
| 62 | WHEN re.event_week_day = 'SUNDAY' THEN (date_trunc('week', CURRENT_DATE) + INTERVAL '6 days')::DATE |
65 | | WHEN re.event_week_day = 'TUESDAY' THEN date_trunc('week', CURRENT_DATE) + interval '1 day'::DATE |
66 | | WHEN re.event_week_day = 'WEDNESDAY' THEN date_trunc('week', CURRENT_DATE) + interval '2 days'::DATE |
67 | | WHEN re.event_week_day = 'THURSDAY' THEN date_trunc('week', CURRENT_DATE) + interval '3 days'::DATE |
68 | | WHEN re.event_week_day = 'FRIDAY' THEN date_trunc('week', CURRENT_DATE) + interval '4 days'::DATE |
69 | | WHEN re.event_week_day = 'SATURDAY' THEN date_trunc('week', CURRENT_DATE) + interval '5 days'::DATE |
70 | | WHEN re.event_week_day = 'SUNDAY' THEN date_trunc('week', CURRENT_DATE) + interval '6 days'::DATE |
| 68 | WHEN re.event_week_day = 'TUESDAY' THEN (date_trunc('week', CURRENT_DATE) + INTERVAL '1 day')::DATE |
| 69 | WHEN re.event_week_day = 'WEDNESDAY' THEN (date_trunc('week', CURRENT_DATE) + INTERVAL '2 days')::DATE |
| 70 | WHEN re.event_week_day = 'THURSDAY' THEN (date_trunc('week', CURRENT_DATE) + INTERVAL '3 days')::DATE |
| 71 | WHEN re.event_week_day = 'FRIDAY' THEN (date_trunc('week', CURRENT_DATE) + INTERVAL '4 days')::DATE |
| 72 | WHEN re.event_week_day = 'SATURDAY' THEN (date_trunc('week', CURRENT_DATE) + INTERVAL '5 days')::DATE |
| 73 | WHEN re.event_week_day = 'SUNDAY' THEN (date_trunc('week', CURRENT_DATE) + INTERVAL '6 days')::DATE |
76 | | WHEN re.event_week_day = 'TUESDAY' THEN date_trunc('week', CURRENT_DATE) + interval '1 day'::DATE |
77 | | WHEN re.event_week_day = 'WEDNESDAY' THEN date_trunc('week', CURRENT_DATE) + interval '2 days'::DATE |
78 | | WHEN re.event_week_day = 'THURSDAY' THEN date_trunc('week', CURRENT_DATE) + interval '3 days'::DATE |
79 | | WHEN re.event_week_day = 'FRIDAY' THEN date_trunc('week', CURRENT_DATE) + interval '4 days'::DATE |
80 | | WHEN re.event_week_day = 'SATURDAY' THEN date_trunc('week', CURRENT_DATE) + interval '5 days'::DATE |
81 | | WHEN re.event_week_day = 'SUNDAY' THEN date_trunc('week', CURRENT_DATE) + interval '6 days'::DATE |
| 79 | WHEN re.event_week_day = 'TUESDAY' THEN (date_trunc('week', CURRENT_DATE) + INTERVAL '1 day')::DATE |
| 80 | WHEN re.event_week_day = 'WEDNESDAY' THEN (date_trunc('week', CURRENT_DATE) + INTERVAL '2 days')::DATE |
| 81 | WHEN re.event_week_day = 'THURSDAY' THEN (date_trunc('week', CURRENT_DATE) + INTERVAL '3 days')::DATE |
| 82 | WHEN re.event_week_day = 'FRIDAY' THEN (date_trunc('week', CURRENT_DATE) + INTERVAL '4 days')::DATE |
| 83 | WHEN re.event_week_day = 'SATURDAY' THEN (date_trunc('week', CURRENT_DATE) + INTERVAL '5 days')::DATE |
| 84 | WHEN re.event_week_day = 'SUNDAY' THEN (date_trunc('week', CURRENT_DATE) + INTERVAL '6 days')::DATE |
195 | | WHEN re.event_week_day = 'TUESDAY' THEN date_trunc('week', CURRENT_DATE) + interval '1 day'::DATE |
196 | | WHEN re.event_week_day = 'WEDNESDAY' THEN date_trunc('week', CURRENT_DATE) + interval '2 days'::DATE |
197 | | WHEN re.event_week_day = 'THURSDAY' THEN date_trunc('week', CURRENT_DATE) + interval '3 days'::DATE |
198 | | WHEN re.event_week_day = 'FRIDAY' THEN date_trunc('week', CURRENT_DATE) + interval '4 days'::DATE |
199 | | WHEN re.event_week_day = 'SATURDAY' THEN date_trunc('week', CURRENT_DATE) + interval '5 days'::DATE |
200 | | WHEN re.event_week_day = 'SUNDAY' THEN date_trunc('week', CURRENT_DATE) + interval '6 days'::DATE |
| 208 | WHEN re.event_week_day = 'TUESDAY' THEN date_trunc('week', CURRENT_DATE)::DATE + INTERVAL '1 day' |
| 209 | WHEN re.event_week_day = 'WEDNESDAY' THEN date_trunc('week', CURRENT_DATE)::DATE + INTERVAL '2 days' |
| 210 | WHEN re.event_week_day = 'THURSDAY' THEN date_trunc('week', CURRENT_DATE)::DATE + INTERVAL '3 days' |
| 211 | WHEN re.event_week_day = 'FRIDAY' THEN date_trunc('week', CURRENT_DATE)::DATE + INTERVAL '4 days' |
| 212 | WHEN re.event_week_day = 'SATURDAY' THEN date_trunc('week', CURRENT_DATE)::DATE + INTERVAL '5 days' |
| 213 | WHEN re.event_week_day = 'SUNDAY' THEN date_trunc('week', CURRENT_DATE)::DATE + INTERVAL '6 days' |
212 | | WHEN re.event_week_day = 'TUESDAY' THEN date_trunc('week', CURRENT_DATE) + interval '1 day'::DATE |
213 | | WHEN re.event_week_day = 'WEDNESDAY' THEN date_trunc('week', CURRENT_DATE) + interval '2 days'::DATE |
214 | | WHEN re.event_week_day = 'THURSDAY' THEN date_trunc('week', CURRENT_DATE) + interval '3 days'::DATE |
215 | | WHEN re.event_week_day = 'FRIDAY' THEN date_trunc('week', CURRENT_DATE) + interval '4 days'::DATE |
216 | | WHEN re.event_week_day = 'SATURDAY' THEN date_trunc('week', CURRENT_DATE) + interval '5 days'::DATE |
217 | | WHEN re.event_week_day = 'SUNDAY' THEN date_trunc('week', CURRENT_DATE) + interval '6 days'::DATE |
| 227 | WHEN re.event_week_day = 'TUESDAY' THEN date_trunc('week', CURRENT_DATE)::DATE + INTERVAL '1 day' |
| 228 | WHEN re.event_week_day = 'WEDNESDAY' THEN date_trunc('week', CURRENT_DATE)::DATE + INTERVAL '2 days' |
| 229 | WHEN re.event_week_day = 'THURSDAY' THEN date_trunc('week', CURRENT_DATE)::DATE + INTERVAL '3 days' |
| 230 | WHEN re.event_week_day = 'FRIDAY' THEN date_trunc('week', CURRENT_DATE)::DATE + INTERVAL '4 days' |
| 231 | WHEN re.event_week_day = 'SATURDAY' THEN date_trunc('week', CURRENT_DATE)::DATE + INTERVAL '5 days' |
| 232 | WHEN re.event_week_day = 'SUNDAY' THEN date_trunc('week', CURRENT_DATE)::DATE + INTERVAL '6 days' |
223 | | WHEN re.event_week_day = 'TUESDAY' THEN date_trunc('week', CURRENT_DATE) + interval '1 day'::DATE |
224 | | WHEN re.event_week_day = 'WEDNESDAY' THEN date_trunc('week', CURRENT_DATE) + interval '2 days'::DATE |
225 | | WHEN re.event_week_day = 'THURSDAY' THEN date_trunc('week', CURRENT_DATE) + interval '3 days'::DATE |
226 | | WHEN re.event_week_day = 'FRIDAY' THEN date_trunc('week', CURRENT_DATE) + interval '4 days'::DATE |
227 | | WHEN re.event_week_day = 'SATURDAY' THEN date_trunc('week', CURRENT_DATE) + interval '5 days'::DATE |
228 | | WHEN re.event_week_day = 'SUNDAY' THEN date_trunc('week', CURRENT_DATE) + interval '6 days'::DATE |
| 238 | WHEN re.event_week_day = 'TUESDAY' THEN date_trunc('week', CURRENT_DATE)::DATE + INTERVAL '1 day' |
| 239 | WHEN re.event_week_day = 'WEDNESDAY' THEN date_trunc('week', CURRENT_DATE)::DATE + INTERVAL '2 days' |
| 240 | WHEN re.event_week_day = 'THURSDAY' THEN date_trunc('week', CURRENT_DATE)::DATE + INTERVAL '3 days' |
| 241 | WHEN re.event_week_day = 'FRIDAY' THEN date_trunc('week', CURRENT_DATE)::DATE + INTERVAL '4 days' |
| 242 | WHEN re.event_week_day = 'SATURDAY' THEN date_trunc('week', CURRENT_DATE)::DATE + INTERVAL '5 days' |
| 243 | WHEN re.event_week_day = 'SUNDAY' THEN date_trunc('week', CURRENT_DATE)::DATE + INTERVAL '6 days' |
232 | | CASE |
233 | | WHEN re.event_week_day = 'MONDAY' THEN date_trunc('week', CURRENT_DATE)::DATE |
234 | | WHEN re.event_week_day = 'TUESDAY' THEN date_trunc('week', CURRENT_DATE) + interval '1 day'::DATE |
235 | | WHEN re.event_week_day = 'WEDNESDAY' THEN date_trunc('week', CURRENT_DATE) + interval '2 days'::DATE |
236 | | WHEN re.event_week_day = 'THURSDAY' THEN date_trunc('week', CURRENT_DATE) + interval '3 days'::DATE |
237 | | WHEN re.event_week_day = 'FRIDAY' THEN date_trunc('week', CURRENT_DATE) + interval '4 days'::DATE |
238 | | WHEN re.event_week_day = 'SATURDAY' THEN date_trunc('week', CURRENT_DATE) + interval '5 days'::DATE |
239 | | WHEN re.event_week_day = 'SUNDAY' THEN date_trunc('week', CURRENT_DATE) + interval '6 days'::DATE |
240 | | END |
241 | | ))) % (7 * re.repeats_every_n_weeks)) = 0 |
242 | | AND se.student_id = correct_student_id |
243 | | ) AS Result |
| 247 | CASE |
| 248 | WHEN re.event_week_day = 'MONDAY' THEN date_trunc('week', CURRENT_DATE)::DATE |
| 249 | WHEN re.event_week_day = 'TUESDAY' THEN date_trunc('week', CURRENT_DATE)::DATE + INTERVAL '1 day' |
| 250 | WHEN re.event_week_day = 'WEDNESDAY' THEN date_trunc('week', CURRENT_DATE)::DATE + INTERVAL '2 days' |
| 251 | WHEN re.event_week_day = 'THURSDAY' THEN date_trunc('week', CURRENT_DATE)::DATE + INTERVAL '3 days' |
| 252 | WHEN re.event_week_day = 'FRIDAY' THEN date_trunc('week', CURRENT_DATE)::DATE + INTERVAL '4 days' |
| 253 | WHEN re.event_week_day = 'SATURDAY' THEN date_trunc('week', CURRENT_DATE)::DATE + INTERVAL '5 days' |
| 254 | WHEN re.event_week_day = 'SUNDAY' THEN date_trunc('week', CURRENT_DATE)::DATE + INTERVAL '6 days' |
| 255 | END |
| 256 | ))) % (7 * re.repeats_every_n_weeks)) = 0 |
| 257 | AND (se.student_id = 91324 OR sje.student_id = 91324) |
| 258 | ) |
| 259 | SELECT |
| 260 | calendar_event_id, |
| 261 | event_name, |
| 262 | event_type, |
| 263 | event_start_time, |
| 264 | event_end_time, |
| 265 | event_date::DATE |
| 266 | FROM Result |
293 | | DECLARE correct_student_id INT; |
294 | | SET correct_student_id = 11111; |
295 | | DECLARE c_term_type VARCHAR(20); |
296 | | SET c_term_type = 'Zimski'; |
297 | | DECLARE c_starting_year INT; |
298 | | SET c_starting_year = 2023; |
299 | | DECLARE c_finishing_year INT; |
300 | | SET c_finishing_year = 2024; |
301 | | DECLARE c_term_subject_id INT; |
302 | | SET c_term_subject_id = 87654; |
303 | | |
321 | | se.term_subject_id = c_term_subject_id |
322 | | AND se.term_type = c_term_type |
323 | | AND se.starting_year = c_starting_year |
324 | | AND se.finishing_year = c_finishing_year |
325 | | AND se.student_id = correct_student_id |
| 324 | se.term_subject_id = 56 |
| 325 | AND se.term_type = 'Zimski' |
| 326 | AND se.starting_year = 2023 |
| 327 | AND se.finishing_year = 2024 |
| 328 | AND se.student_id = 91324 |
346 | | ct.term_subject_id = c_term_subject_id |
347 | | AND ct.term_type = c_term_type |
348 | | AND ct.starting_year = c_starting_year |
349 | | AND ct.finishing_year = c_finishing_year |
350 | | AND ct.student_id = correct_student_id; |
| 349 | ct.term_subject_id = 56 |
| 350 | AND ct.term_type = 'Zimski' |
| 351 | AND ct.starting_year = 2023 |
| 352 | AND ct.finishing_year = 2024 |
| 353 | AND ct.student_id = 91324; |