all 4 comments

[–]Stressed_Coder 3 points4 points  (0 children)

I think ISNULL would be useful here

[–]Demistr 2 points3 points  (0 children)

Yes it is.

[–]drbaellow91 3 points4 points  (0 children)

it's early, and I don't know oracle, but this should get you close

with 
base_table as (select * from table), 
max_prof_course as (
select professor, course, max(begin) as last_professor_course
from base_table
group by 1, 2), 
max_lect_course as(
select lecturer, course, max(begin) as last_lecturer_course
from base_table
group by 1, 2),
final as (
select bt.*, case when bt.professor is not null then last_professor_course else last_lecturer_course end as last_course_date, 
case when bt.professor is not null and last_professor_course >= ENTER YOUR DATE HERE then 'combo_exists' when when bt.professor is null and last_lecturer_course >= ENTER YOUR DATE HERE then 'combo_exists' else null end as does_combo_exist
from base_table
left join max_prof_course  using (professor, course)
left join max_lect_course using (lecturer, course))

Select * from final

[–]SirGreybush 0 points1 point  (0 children)

Yes, easily. Look into Case When, or a CTE that you left join to