I need to list all of the subject's "neptuncode", "subjectname" and "examdate" ordered by subjectname.

But if someone enrols the subject for the first time, I have to list (recommend them) examdate(s).

I tried this code:

SELECT neptuncode, subjectname, examdate
FROM enrollments, subjects
WHERE enrollments.student = (SELECT students.student_id FROM students)
AND enrollments.firstenroll = 1
ORDER BY subjectname;

but it didn't work.

I attach my tables here:

enter image description here

  • 3
    Please update your question with actual table definitions in the form of DDL, sample data in the form of actual insert statements and your expected results from your query. – Scott Hodgin Nov 6 at 21:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.