I have been butting my head against this problem for the past 4 hours, and I have to tap out. I know I can't be too far from correct I am just not sure what the missing ingredients are.

Here is the problem question:
Student status: List of all students and their enrollment status
Fields: student last name and first name (comma separated), years enrolled, academic advisor last name and first name (comma separated) Sort: years enrolled Input: none Filter: only include currently active students and My code:
SELECT student_id,std_l_name, std_f_name, faculty_l_name, faculty_f_name,student_id_fk,enroll_date,MONTHS_BETWEEN(CURRENT_DATE ,enroll_date)
V1:

FROM STUDENT, FACULTY,ENROLLMENT
WHERE FACULTY.faculty_id=STUDENT.faculty_id_fk3
AND
STUDENT.student_id=ENROLLMENT.student_id_fk
AND ENROLLMENT.enroll_status='active'
ORDER BY ENROLLMENT.enroll_date;

V2:

SELECT student_id,std_l_name, std_f_name, faculty_l_name, faculty_f_name,student_id_fk,enroll_date,MONTHS_BETWEEN(CURRENT_DATE ,enroll_date)
FROM STUDENT, FACULTY,ENROLLMENT
LEFT OUTER JOIN FACULTY 
ON STUDENT.student_id=FACULTY.faculty_id
WHERE
STUDENT.student_id=ENROLLMENT.student_id_fk
AND ENROLLMENT.enroll_status='active'
ORDER BY ENROLLMENT.enroll_date;

Recommended Answers

All 2 Replies

I wonder if this is the usual homework assignment I see at https://stackoverflow.com/questions/7971950/sql-find-names-of-students-who-enroll-in-all-courses

It's a shame the course lacks building your skill up to this point. Go back over the prior material to find out how to build your SQL queries.

When asking a question, be sure to end it with a question mark so everyone knows that's the question.

UP DATE I GOT IT WORKIGN WITH THIS CODE!

SELECT S.student_id AS "STUDENT ID",S.std_l_name AS "STUDENT LAST NAME",S.std_f_name AS "STUDENT FIRST NAME",S.faculty_ID_FK3 AS "FACULTY ID",F.faculty_l_name AS "FACULTY LAST NAME",F.faculty_f_name AS "FACULTY FIRST NAME",(MONTHS_BETWEEN(SYSDATE,E.enroll_date)/12) AS "YEARS ENROLLED"
FROM STUDENT S 
INNER JOIN FACULTY F ON S.faculty_ID_FK3 = F.faculty_id
INNER JOIN ENROLLMENT E ON S.student_id = E.student_id_fk
WHERE E.enroll_status ='ACTIVE'
ORDER BY E.enroll_date DESC;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.