I read here:
Can we have multiple "WITH AS" in single sql - Oracle SQL
that if I have 2 tables in my WITH clause, I can reference the first tables in the my second table's where clause. However, I have had no luck doing this in practice. Any insights would be appreciate.
I've tried every iteration of aliases that I can think of when trying to access the first table.
with term as (
select course_reference_number, academic_period from student_course ),
term2 as (
select subject_desc, academic_period from student_course where
and term.course_reference_number = 22638)
select term.*, term2.*
from term, term2
where term.academic_period= term2.academic_period;
I get the error: ORA-00904: "TERM"."COURSE_REFERENCE_NUMBER": invalid identifier